[RESOLVED] Collision before movement

Hey all!

I use standard collision check pre/post. But I need to be able to check if a collision occurs at the moment of creation. i.e. as the object is spawned potentially ontop another object. so pre/post don’t work as the collision has already happened; any help appreciated

Cheers

Hi m.hula,

There’s a little “trick” to this that should work (I’ve used it before). When you create the new object, quickly deactivate it and reactivate it in 2 consecutive lines:

[lua]

object.isBodyActive = false

object.isBodyActive = true

[/lua]

This should trigger a collision event when the object regains sensory state… and likely it will trigger a collision event on the other object when it goes inactive, if you’re sensing collision on it too (not just the object that’s being newly placed).

Brent

Hey!

Works a treat; THANKS!

Actually this doesn’t work :frowning: Can a ray cast perhaps be used ? I need to know on spawn if colliding not 1frame later …

Hi m.hula,

There’s a little “trick” to this that should work (I’ve used it before). When you create the new object, quickly deactivate it and reactivate it in 2 consecutive lines:

[lua]

object.isBodyActive = false

object.isBodyActive = true

[/lua]

This should trigger a collision event when the object regains sensory state… and likely it will trigger a collision event on the other object when it goes inactive, if you’re sensing collision on it too (not just the object that’s being newly placed).

Brent

Hey!

Works a treat; THANKS!

Actually this doesn’t work :frowning: Can a ray cast perhaps be used ? I need to know on spawn if colliding not 1frame later …