- Home /
move object with Vector3 by position
i have multiple Game Objects in different positions and i want to move each on of them down alone on any click when mouse enter in example :
wall position 1, 0.7, 1
wall position 6, 0.7, 3
wall position 2, 0.7, 2
wall position 5, 0.7, 5
wall position 3, 0.7, 4
wall position 4, 0.7, 6
and i want all of them in the same (x, y) pos and need to move them just on the y axis THIS IS THE SCRIPT
var OnOff : boolean;
var wall : GameObject;
var target : GameObject;
function Start ()
{
OnOff = true;
}
function OnMouseEnter ()
{
renderer.material.color = Color.black;
if (OnOff == true)
{
if (Input.anyKey)
{
transform.position = Vector3(wall, target, wall);
OnOff = false;
}
}
}
function OnMouseExit ()
{
renderer.material.color = Color.white;
}
Answer by StormSabotage · Dec 10, 2013 at 01:01 PM
You should use transform.Translate() method, read THIS.
Thanks any way i found the fix in past this question is late
so any way i gave you Thumb up
Your answer
Follow this Question
Related Questions
Position in Vector (C#) 1 Answer
Cannot implicitly convert type 'int' to 'UnityEngine.Vector3' 3 Answers
How do you get the vector3 of one object and assign that vector3 to another object? 1 Answer
Add posititons relative to transform 2 Answers
How to detect if transform.position is not vector3 + 100 on x position 1 Answer