Question by
Davide-Barbieri · Feb 08, 2016 at 05:22 PM ·
rigidbodymoving
how to make 3 instances with interchangeable position
i need to make this for a game. basically i have three objects, and when i press left mouse, the one behind the first pass in front, while if i press right mouse it's the third one that goes in front of the first something like this: http://imgur.com/fMCj38n
here's the code, but that's the big problem:
#pragma strict
var sphere:int=0;
var cube:int=0;
var capsule:int=0;
var pos1:float=3;
var pos2:float=0;
var pos3:float=-3;
private var target:Transform;
var message:String="-ciao-";
var weight:Rigidbody;
function Start () {
// gameObject.name = "Pippo";
//target = a;
// player = gameObject.FindGameObjectWithTag("Player").transform;
}
function Update () {
if(Input.GetMouseButtonDown(0)){
transform.position = Vector3(pos3,0,0);
}
if(Input.GetMouseButtonDown(2)){
transform.position.x = pos1;
}
}
basically, the objects begin revolving on each other, what's the problem?
Comment