GetAngle & GetPosition Troubles

Post » Tue Nov 20, 2012 6:21 am

Hello,

GetAngleZ and GetPositionZ (didn't test the others) are not responding. I have a ship as an activator which has 4 other objects attached to it through AddHavokBallAndSocketConstraint and I'm moving them all through ApplyHavokImpulse. None of them respond to GetAngle and GetPosition functions. It returns the initial value correctly, where the object initially started, but all following calls keep returning the initial position and angle values.

Why? I'm sure I'm calling it correctly. Is it a bug with the constraints? And how can I overcome it???

Just in case, this is the piece of code giving me troubles:
Spoiler
Event OnKeyDown(Int KeyCode)	If KeyCode == 72 ;FORWARD - Num8		AngleZ = Self.GetAngleZ()		;ControllerBuoyFront.ApplyHavokImpulse(Math.Sin(AngleZ), Math.Cos(AngleZ), 0.0, 800)		ApplyHavokImpulse(Math.Sin(AngleZ), Math.Cos(GetAngleZ()), 0.0, 70)	EndIf	If KeyCode == 80 ;BRAKE - Num2		AngleZ = Self.GetAngleZ()		ApplyHavokImpulse(Math.Sin(AngleZ), Math.Cos(AngleZ), 0.0, -70)	EndIf	If KeyCode == 75 ;RIGHT - Num4		AngleZ = Self.GetAngleZ() + 90		ControllerBuoyBack.ApplyHavokImpulse(Math.Sin(AngleZ), Math.Cos(AngleZ), 0.0, 100)	EndIf	If KeyCode == 77 ;LEFT - Num6		AngleZ = Self.GetAngleZ() - 90		ControllerBuoyBack.ApplyHavokImpulse(Math.Sin(AngleZ), Math.Cos(AngleZ), 0.0, 100)	EndIfEndEvent

The impulses are working. Only the GetAngle part isn't. The forward key is always moving the ship in the same direction, regardless of it's angle...
User avatar
claire ley
 
Posts: 3454
Joined: Fri Aug 04, 2006 7:48 pm

Post » Tue Nov 20, 2012 9:01 am

Hello.

Does your ship ever rotate? When you push it to the left, does it only translate to the left, or does it also rotate towards the left direction?
Because if it's not rotated, then the Z angle of course stays constant, whatever the direction you translate it to, ahd the behavior you observe is expected.

MoveTo can be used to both rotate and translate an object. It has some collisions oddities with meshes flagged as Static rather than MoveableStatic (I don't rememeber the details but this is something to be edited in NifSkope I believe).
Or you could just rotate you object on "every frame" by an amount proportional to the distance it traveled.
User avatar
Kelvin
 
Posts: 3405
Joined: Sat Nov 17, 2007 10:22 am

Post » Tue Nov 20, 2012 7:54 am

Hello Perdev,

It seems that objects moved with ApplyHavokImpulse are not registered by the game engine. It moves the 3D object and it's collision, but for the engine, the object didn't move at all. andyw discovered this with his Dwemer Flying Machine mod, and explained it to me. He explained it as if the engine would create a ghost object. That explains why the functions always returned the original object's position and angle. You can work around this by using the objects nodes, as they do travel with the 3D object.
User avatar
dean Cutler
 
Posts: 3411
Joined: Wed Jul 18, 2007 7:29 am

Post » Mon Nov 19, 2012 7:37 pm

Thank you for coming back here to provide this information, Dielos, this could prove to be useful. :)
User avatar
Sherry Speakman
 
Posts: 3487
Joined: Fri Oct 20, 2006 1:00 pm


Return to V - Skyrim