Hi everybody ! ( Sorry for my english ^^’ )
I’m doing a VR game, but I have some weird things happenning …
At the beggening of my project , I crated my first scene with the Original position/Rotation of the Camera RIg prefab. But , When I begun to create a other scene and trying to face the player to the right direction ( For exemple, if you go in a door, when the player appear in the new room, I Want the player face a specific direction, I don’t want the player appear and facing the door, but the contrary)
So now i’m rotate the root object to face the camera in what direction I want.
And here the problem appear … My game it’s a Magic game where you can throw spell with your hand.
For that, nothings complicated, I get the velocity of the hands, get the vector direction , and throw the spell in the direction of the hand velocity. And before that, It was working perfectly!
But now, the spell are throw in a wrong direction. Each time I apply new rotation of parents object, hand’s velocity are wrong !
It’s like if my hands rotate visualy, but not with physics .
After spawn my player and rotate it, If I throw spell, the spell go in the same direction of what I had with original rotation …
Here the video :
here the script for the Velocity hand:
if(pose.GetVelocity().magnitude > 2f)
{
if(ss.open == true)
{
Debug.Log(" Delocity :" + pose.GetVelocity());
Spctl.instance.LaunchSpell(hand, pose.GetVelocity());
}
}
Here the code when I set direction velocity to my spell:
transform.rotation = Quaternion.LookRotation(baseVelocity.normalized);
And the physics:
rb.velocity = transform.forward * speed * Time.fixedDeltaTime;
EDIT : I have a clue, maybe the velocity that I get is Local, So I have to translate to world space velocity, but if i do transform.TransformDirection(pose.GetVelocity()) : The direction always go wrong …
So if someone can explain me how it’s happen ? Or a tips to fix that i’ll really appreciate ![]()
Have a good day ![]()