- Home /
Why do my commands invert when I turn the camera around?
In my game when you turn the camera around, the commands flip. Example: WASD turns into SDWA How can i fix this?
What are you using to control your actors? You haven't linked anything for context.
I suspect that you're rotating only the camera, not the character: this would keep the character moving along its axes while the camera is looking to another direction - very confusing! Post the scripts for character and camera movement.
it's the same concept as when you're tightening a screw from the bottom up position but you're looking down on it ins$$anonymous$$d of looking up at it.
basically by flipping the camera everything is now mirrored. i'd add an if statement making your vectors all * -1 when the camera flips.
so if your movement for the A key is to go left I'd write this in my movement method
void $$anonymous$$ovement()
{
if (cameraFlipped == true)
{
if(input.getkeydown(keycode.A)
{
transform.translate(-transform.left * speed * time.deltatime);
}
}
else
if(input.getkeydown(keycode.A)
{
transform.translate(transform.left * speed * time.deltatime);
}
}
that little - is what you're flipping.
Your answer
Follow this Question
Related Questions
Command line feedback 4 Answers
How do I hide GUI? 3 Answers
Client interact with World Objects 0 Answers
Why is the command function not being called on the client? 0 Answers
Object reference not set to an instance of an object with Assembly-CSharp 0 Answers