Jump to content

[Solved] How to keep forward with rotation character


Recommended Posts

Hi everyone
 

I try to make a character move in  forward direction of his model 3D
i make a rotation with

i take x and y from ControlsApp.MouseDX and ControlsApp.MouseDY

node.WorldRotate(x,y,0);

How to move forward after this this rotation
?
 
I know atan2 will be necessary but i don't know how to implement it

Thank you for your help and unigine engine
Edited by Plorol
Link to comment

There is simple trick for this.

What I would do.

1. Place your object as a child to parent NodeDummy.

2. Move Forward on NodeDummy. and keep rotating your child object.

I hope this will solve your issue. 

Regards,

Rohit

Link to comment

thank you very much for your answer Rohit,
it works so far like that, i mean if my mesh  rotate by 90° on Z, if i add to its position vec3(0,10) to move forward, it'll move like before any rotation

i give a link to a tutorial about rotate and direction (excuse me, it's not adversiting)

 

i don't know how to implement this in unigine

Edited by Plorol
Link to comment
vec3 dir = node.GetWorldDirection(MathLib.AXIS.Y);
dir.Normalize();
node.SetWorldDirection(dir,vec3.UP,MathLib.AXIS.Y);
node.WorldTranslate(dir * 20.0f * Game.IFps);

I found it in bullet.node and firecontroller from thirdperson demo

Link to comment
  • Plorol changed the title to [Solved] How to keep forward with rotation character
×
×
  • Create New...