unity3d - C# OnTriggerEnter, Pick up an object. OnTriggerExit, drop the object -
i'm trying sprite pick cube when encounters one, if isn't carrying one. if is, drop cube carrying.
this have right now.
void ontriggerenter(collider other) { if (other.tag == "cube") { other.transform.position = this.transform.position; } }
i tried telling cube become child of sprite. wasn't working. put cube sprites position when trigger entered, cube stays in position while sprite wonders off.
with code,you can change cubes position players position 1 time.if want cube move character should make child of character.
try using code;
void ontriggerenter(collider other) { if (other.tag == "cube") { other.transform.parent = gameobject.transform; } }
ps:i don't have access unity now.some coding mistakes can occur.
Comments
Post a Comment