- Home /
How to move gameobjects using the world position?
So, I'm trying to figure out how to write a script which will be able to detect when game objects are in a certain world position, to transform those game objects and move them up by say 1.
Hope that makes sense, if not please ask and I'll try my best to explain in further detail. Really would appreciate any help.
Create an empty gameobject with a trigger box collider. If a gameobject enters that area you can perform whatever action you want.
Answer by N1warhead · Oct 24, 2016 at 11:23 PM
You can either do what @doublemax above said or if you don't want to use Triggers then use position detection.
So lets say for example we create a new Vector3 (or2 if this is 2D). so example
public Vector3 positionToFind = new Vector3(100,100,100);
void Update(){
if(transform.position = positionToFind){
// Do something.
}
}
Answer by dcex1 · Oct 25, 2016 at 08:30 AM
Excellent suggestions! Will be giving them a go immediately :) Thank you
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
comparing variables of gameobjects in an array 2 Answers
Switches and doors - avoid circular dependencies 2 Answers
Points not adding to score in unity text 3 Answers