Problem with event.other during collision

Hi @marcodelia1900,

According to documentation in global handler do not appear variable named event.other. It only exists in local handler.

Object References

Depending on whether collisions are detected locally or globally, references to the objects involved will vary. For more information about these two collision handling methods, see the Collision Detection guide.

 

Local Collision Event   Global Collision Event

 

event.target or self      event.object1

event.other                    event.object2

event.selfElement        event.element1

event.otherElement    event.element2

 

I would use local collision handler for one-many colision detection as @XeduR @Spyric suggested you.

 

Have a nice day:)

 

ldurniat

Hi @Idurniat,

the solution you quoted was the “global” one… the first solution that gave me same problem was the “local” one.

In local collision handling, you need to pass ( self, event ) into the function. I only said that you seemed to have used global as you hadn’t included both of them. This could be a reason as to why your event.other is nil.

But really, in the future, if you need help with debugging, try uploading a small sample project to the forums that demonstrates your issue. That way people will have a much easier time helping you. At this point it is just about guessing why event.other doesn’t exist within the scope of the function.

I can send you my project in private if you want (is really small)

Sure, you can send it to me via private discussion or at eetu.rantanen@spyric.com.

Just posting a status update here. I already sent the updated project back to marcodelia1900.

The collision function itself worked fine. The problems were in function scene:show, which was run during both “will” and “did” phases. This meant that all display objects were created twice and the reference to the original ball was lost immediately. Additionally, the bricks also created in a way that each subsequent brick took over the variable’s reference, etc.

So, when the collision function was initially called, it was called because two overlapping balls (one without a reference) were colliding.

There’s a lot left to work on the project, but at least now these major issues are addressed. :smiley:

Good luck!

Thanks again bro!