Changing player's heading

Post » Tue Jan 29, 2013 8:35 pm

Hi,
I'm trying to make a lock-on combat system (like in a zelda game). I got most of it figured out but i am stuck on some very annoying glitches:

Basically when i change the player's Z angle it seems to break his animation, the sounds stutters very briefly while he gets "teleported" to new heading, and it looks like he jumps in place. The update being applied very frequently, this give some very ridiculous results. I think the "teleport" messes up with the collision engine somehow...

I tried using :
-player.setlookat(target,true), which should set my pathing to look at the target
-player.setangle(0,0,player.getheadingto(target)), resulting in the crazy dance above
-doing the math myself arctangent(targetpos-playerpos)
-translateto, splinetranslateto : the rotation doesnt seem to get applied (is it overridden by something? i turned off player controls, but the same happens)

So before giving up i'd like confirmation.. did i miss some function? Is it really impossible to tamper with the player's orientation without those side-effects?

here's the update code :


Event OnUpdate()
;trackcaster.StopTranslation()

float pX = trackcaster.GetPositionX()
float pY = trackcaster.GetPositionY()
float pZ = trackcaster.GetPositionZ()
float angleX = trackcaster.GetAngleX()
float angleY = trackcaster.GetAngleY()
float head = trackcaster.GetHeadingAngle(trackTarget)
float angleZ = trackcaster.GetAngleZ() + head

if math.Abs(head) > 0
; trackcaster.TranslateTo(pX,pY,pZ, angleX, angleY, angleZ,20,200)
trackcaster.SetAngle(angleX, angleY, angleZ)
; trackcaster.SplineTranslateTo(pX, pY, pZ,angleX,angleY,angleZ, 100, 100,100)
endif

;trackcaster.SetHeadTracking(true)
;trackcaster.SetLookAt(tracktarget,true)

RegisterForSingleUpdate(1)
endEvent
User avatar
Becky Cox
 
Posts: 3389
Joined: Thu Jun 22, 2006 8:38 am

Return to V - Skyrim