How do I link to a Collider’s related Transform component in a JavaScript? If for some reason I can’t, how can I alter an object’s coordinates when a collision has been detected?
1 Answer
1My goal is to direct an object to move down, by decreasing the y value of transform.position when the object comes into contact with another. The stationary object that the moving object comes into contact with contains the script, I have my collision detector in the trigger, using OnTriggerEnter.
OnTriggerEnter(other : Collider) //other is the object that should get moved down. Anyways… I figured it out. I was trying to have the move command be in a different function and that just wasn’t working, I’ll just do it in the OnTriggerEnter function, that’s working fine and should simplify the next bit.
Can you describe more what you are trying to do? You can change an objects coordinates by modifying its Transform.position (which you would access with something like 'collision.transform.position' inside of OnCollisionEnter()), but I'm guessing there is more here.
– robertbu