I am trying to make a shape object that spawns within the player turn into a physics body and trigger a collision with the player after a short delay. This isn’t working though. The player is having to exit and re-enter the collision zone while it is active for it to register. The collision will work fine if I delete the delay from the shape object, but I need the delay. Basically I have a warning marker and then the warning marker turns into desired collision object…if the player doesn’t leave the warning marker zone it is supposed to register the collision.
object.isSleepingAllowed has no effect even when applied to both objects. Both objects are orange in the physics.setDrawMode( “debug” ), so they r both active yet no collisions occur until they exit and re-enter eachother if there is a delay present. I either have the delay as being the entire physics.body assignment or an id assignment that marks in the local collision event listener of the player…neither variance makes any difference. Player is set to dynamic, the obj is set to dynamic and isSensor=true
*I was using transition.to to assign the id and/or physics body and there’s some kind of conflict with the system. I gaveup and just created a separate bullet timer that assigns both the id and physics body to the lasers at the time I want, and this is working. There’s nothing in the docs saying this shouldn’t work. This bit shouldn’t matter other than the first line which is nonspecific:
Some objects will not behave as you may expect during or following a transition. For instance, many do not support scaling or post-declaration resizing, so you should not attempt to perform an
xScale,
yScale,
width, or
height transition upon them. Another example is [physics] bodies: if you scale or resize the physics object using a transition, the actual physics body will **not** scale along with that transition.
`
So I want to do the transitions and halfway through after the first two...I call faker and assign them halfway through. It's causing the physics not to work this way though. Now The solution outlined above is working with these transitions going....so that begs the question why I can't just define it within faker.
local function faker(current_obj)
--can't define a physics body or set an id for existing body here and get it to work (unless u exit and re-enter the collision anyways)
--the scaling part of the doc isn't the issue, its not scaling in a way where the collision doesn't exist, it always exists or always doesn't I've tested it. Its the defining 'in here' part that is creating this weirdness.
end
for i=0,1 do local n=1500
transition.to(obj, {delay=i*n, time=200, width=20, strokeWidth=5, transition=easing.inOutBack, onRepeat={width=100} } )
transition.to(obj, {delay=200+i*n, time=900, strokeWidth=.4, cornerRadius=0, width=0, onComplete=faker, transition=easing.outCirc } )
end