Collision Detection / Transition.to

I have a normal collision detection listener set up and I just want whatever I collide with to fade out. Why can’t I do something like this?

local function enemyCollides (event) if event.phase=="began" then print(event.target.type) transition.to(event.target.type ,{time=2000,alpha=0}) end end

When I print event.target.type it’s the name of the target that should fade out but yet it doesn’t fade that object out in the transition to. Not sure why?

I think you want:

transition.to(event.target,{time=2000,alpha=0})

Try that and let us know how it goes. 

Also, note that this will repeat the transition for every “began” phase that occurs in this collision. This may or may not be what you want, but you might not see the functionality that you’re going for. I’d suggest writing in a print function that spits out the collision phases so you can see when the “began” and “ended” phases occur.

Thanks Alex, I was just testing this out so I didn’t set every part of the phases but I understand what you are saying. And yes that worked. So thank you again for the speedy response. I do appreciate it.

I think you want:

transition.to(event.target,{time=2000,alpha=0})

Try that and let us know how it goes. 

Also, note that this will repeat the transition for every “began” phase that occurs in this collision. This may or may not be what you want, but you might not see the functionality that you’re going for. I’d suggest writing in a print function that spits out the collision phases so you can see when the “began” and “ended” phases occur.

Thanks Alex, I was just testing this out so I didn’t set every part of the phases but I understand what you are saying. And yes that worked. So thank you again for the speedy response. I do appreciate it.