Hello, guys, I’m stuck on problem which I can’t resolve without somebody’s help. I will be very glad if someone will help me.
I need to make some moving object, i’ve write the script but the object is go down from starting position and then is repeating the same. I need to moving object from center for the same distance up and down.
public float speed = 0;
public float switchTime = 2;
void Start()
{
GetComponent<Rigidbody2D>().velocity = Vector2.up * speed;
if (Vector2.Equals)
InvokeRepeating("Switch", 0, switchTime);
}
void Switch()
{
GetComponent<Rigidbody2D>().velocity *= -1;
}