I have the following four gameObjects, they have, respectively, the rotations: -90, 0, 90, 180. I want them to move as denoted in the image below

enter image description here

This is what I got so far:

public class Projecttile : MonoBehaviour
    public float speed;

    private void Update()
        transform.Translate(transform.up * speed * Time.deltaTime);

The result of my code is the following: enter image description here

Why does my code result in this outcome, and how can I make each gameObject move in the direction it's facing?

  • \$\begingroup\$ Note: Each projecttile only got the Projecttile script attached to it, there is nothing else interfering with it. \$\endgroup\$ – Sebastian Nielsen Apr 9 at 20:15
  • \$\begingroup\$ Did you read the docs on transform.Translate to verify what coordinate space it uses when you don't provide a Space parameter? Or did you mean to type Vector3.up instead of transform.up? \$\endgroup\$ – DMGregory Apr 9 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.