AnupSP
1
Hi,
I’m a complete noob here.I have a Sprite car from top view and I need to add simple movement to it.
i have assigned two inputs A and B.
if i press button A - then the sprite should rotate in a certain angle (maybe 20 degrees)
and move forward in that direction.
if i press button B - then the sprite should do the same in the opposite direction.
And if I press both A&B together - then the sprite should simply move forward without any change in
direction angle.
i have attached an image to show the process.
So far I have only managed to get the sprite to move forward.
Please help me with the script
thanks in advance…
Are “a” and “b” keyboard buttons? You might want to look at these links:
https://docs.unity3d.com/Documentation/ScriptReference/Transform-localEulerAngles.html
That should give you an idea of how to do the rotation.
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddRelativeForce.html
Thats a way of moving the car.
Remember that you can do to check two things at once, in this case you probably will want:
if(input.GetButtonDown("A") input.GetButtonDown("B") ){
//Move forward
}
else if (input.GetButtonDown("A") )
{
//Move left
}
//Repeat for right
AnupSP
3
thanks,
lemme check this out and will let ya know…
“a” “b” represent buttons,they could be keyboard or touch.
i’m planning to call em left and right for now…
i didnt know about the thing…actually i dont know java at all…
Im only familiar wih visual basic…and java looked similar to it…thas why ima
using it…
once again thanks for the info