THIS IS ALL 2D GAME
I have many prefabs/gameobjects that I want to move on their own . I have a script and it does move but only up when I put the “up” in the code when I switch it to down it wont move? I assumed if I put in down it would freely move down , right move right etc etc but doesn’t work only up works. What else do I need to include in this script so I can have objects move down or left or right and random for another prefab?
I would like to know what im doing wrong and or missing.
so another words what words do I have to include and where in this script do I include them so I can choose what direction I want certain objects to move on their own at start of game? if you see I have up and it does go up but I need other options like sides down and random movement… also how do I adjust the speed of them the speed variable i had in 1st code wasn’t working when I input it so I then redid it all and used transform.translate as you see on bottom of 1st attempt
like asteroids in a shooting ship game asteroids coming down/ moving on their own
with the code I have they move up but I want to know how to make them move down, right, left and randomly anywhere also.
heres my JavaScript below
THIS IS A 2D GAME
/*
var shootForce: float;
var speed : float;
function Start () : void {
rigidbody2D.velocity = transform.up * speed;
//rigidbody2D.AddForce(Vector2.down * speed);
// rigidbody2D.AddForce(transform.forward * shootForce, ForceMode2D.Impulse);
}
*/
function Update() {
// Move the object forward along its z axis 1 unit/second.
transform.Translate(0, 0, Time.deltaTime);
// Move the object upward in world space 1 unit/second.
transform.Translate(0, Time.deltaTime, 0, Space.World);
}