Transition pass through obstacles

is there a way to “go around” the obstacles when using transition?

I am using the following code to move my player object

local movePlayer = function(event)
local distancep = math.sqrt((player.x - event.x) * (player.x - event.x) + (player.y - event.y) * (player.y - event.y))
transition.to(player,{time=distancep * 10, alpha=0, x=event.x, y=event.y,transition = easing.linear} )
end
However, i notice that it will just pass through the obstacle object even though i set the obstacle to “static”

How can i fix this?

Thanks [import]uid: 237763 topic_id: 37428 reply_id: 67428[/import]

You have to detect the collision between your player and your object and abort the transition if there is a collision. Transitions are not part of the physics engine and will move from point a to point b unless you stop it. [import]uid: 199310 topic_id: 37428 reply_id: 145593[/import]

So i wrote the following
player.preCollision = function(self, event)
player.x =player.x + math.random(0,2)
player.y = player.y + math.random(0,2)

hoping to readjust the position before the collision, but it shows that
“ERROR: Cannot translate an object before collision is resolved”

So is there anyway to go around the obstacle? [import]uid: 237763 topic_id: 37428 reply_id: 145620[/import]

Hello,
Certain things cannot be done in the same “app cycle” as a collision. In this scenario, you can use normal collision detection (not pre-collision), then on collision, perform your translate after a very short, imperceptible timer of 10-20 milliseconds. This should solve the error message you’re getting.

Brent [import]uid: 200026 topic_id: 37428 reply_id: 145622[/import]

You have to detect the collision between your player and your object and abort the transition if there is a collision. Transitions are not part of the physics engine and will move from point a to point b unless you stop it. [import]uid: 199310 topic_id: 37428 reply_id: 145593[/import]

So i wrote the following
player.preCollision = function(self, event)
player.x =player.x + math.random(0,2)
player.y = player.y + math.random(0,2)

hoping to readjust the position before the collision, but it shows that
“ERROR: Cannot translate an object before collision is resolved”

So is there anyway to go around the obstacle? [import]uid: 237763 topic_id: 37428 reply_id: 145620[/import]

Hello,
Certain things cannot be done in the same “app cycle” as a collision. In this scenario, you can use normal collision detection (not pre-collision), then on collision, perform your translate after a very short, imperceptible timer of 10-20 milliseconds. This should solve the error message you’re getting.

Brent [import]uid: 200026 topic_id: 37428 reply_id: 145622[/import]