Home Game Development unity – Move object on World’s XYZ axes

unity – Move object on World’s XYZ axes

0
unity – Move object on World’s XYZ axes

[ad_1]

I’m making an attempt to maneuver my Character on the world’s XYZ Axes, however how do I get them?

I’m making an attempt to do that as a result of my Player is form of a Sphere and is rolling round, so its xyz instructions are rotating.

I believed I can repair this if I make it transfer with the world’s xyz.

Does somebody understand how to do that, or one other option to repair this downside?

This is my present code to maneuver my olayer object:

    public float playerSpeed = 20;
    
    public float verticalInput;
    public float horizontalInput;
// Update is known as as soon as per body
void Update()
{
    verticalInput = Input.GetAxis("Vertical");
    rework.Translate(Vector3.ahead * Time.deltaTime * playerSpeed * verticalInput);

    
    
    horizontalInput = Input.GetAxis("Horizontal");
    rework.Translate(Vector3.proper * Time.deltaTime * playerSpeed * horizontalInput);
}

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here