Move object on collision

Hi,
I can’t for the life of me figure out how to change the x-y position of an object when it collides with another object (in this case, I want it to be moved to the middle of the screen when it hits this object. How would this be done? Thanks

-David [import]uid: 10942 topic_id: 3397 reply_id: 303397[/import]

Look in the documentation for physics bodies, if you want the physics engine to do the moving, or if you want to specifically move the object regardless of physical interaction look in the collision detection section: http://developer.anscamobile.com/content/game-edition-collision-detection

If, upon collision detection, you want the object to move directly there (without passing Go, as it were) use ‘transition.to(…)’: http://developer.anscamobile.com/content/animation#transition.to_target_params_

What you’re talking about is very easy and straight forward, you’ll have a lot of fun learning about it if you read the docs.

Matt. [import]uid: 8271 topic_id: 3397 reply_id: 10249[/import]

Matt,
Thanks for your help! The hardest part I was having was figuring out how to select the object that had collided and perform an action on it. After several hours of looking around, I found this:
[lua]event.other.parent:remove(event.other)[/lua]
which lets me remove the object and then it can be recreated wherever I want. Thanks again! [import]uid: 10942 topic_id: 3397 reply_id: 10270[/import]

You can also use:

[lua]object:removeSelf()[/lua] [import]uid: 8271 topic_id: 3397 reply_id: 10283[/import]