I’m trying to detect collision on a game object and then move another object in response. However, my Udon does not seem to do anything and I’m hoping someone here can point me in the right direction.
Here is what I created:
My intended flow is:
- The target object has an OnTriggerEnter, which is what I believe happens when it triggers an object that has been set Is Trigger to true.
- I check that the triggered object is the “GameActivateCollider”.
- If so, then I set the position of TestCube’s transform.
The object that I intend to collide with the “GameActivateCollider” has the following script settings which I think should pass in the correct objects:
Can anyone tell me what is wrong or missing with this?
Hey, maybe this will help you if I understand correctly:
Object X enters (GameActivateCollider) → Object Y moves (TestCube).
Thanks. I’ll give this a try.
It works! Thanks so much, I’ve been trying to crack this one for ages.
Bonus question: if I want to move several objects, is there a way to do this optimally?
I would think putting the objects you want to move together into an array would be an optimal way to do it.
This should work:
I just changed the variable to an array and I then step through each index, and set its position using a FOR loop.
And of-course adding reference to all the GameObjects I would like to move.
This will however set each GameObjects position to the same position. You’ll have to see how to do them individually by checking the value of the index and doing something with that GameObject’s transform before it steps to the next index I guess.
Awesome! I’ll give this a go.
This worked perfectly btw. Thank-you very much!