Setting up simple "bounce off" using events, no behaviours

0 favourites
  • 6 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • I was wondering if anyone could point me towards setting up some bouncing off and mini mock up collisions using only events and not behaviours.

    The reason is twofold, firsly to actually learn to code a bit and not just use behaviours, and secondly I am using custom movements which do not work with the bullet/solid behaviours.

    I am browsing the forums now, but just thought I would ask in the meantime.

    Thanks for the help.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I guess it would consist of getting the angle between the object and the object it bounces from on collision and setting the movement angle accordingly..

    Getting the angle is easy:


  • Well the hardest part at the moment it seems, is that I have a box constantly moving by set x=selx+60*dt, and another box controlled by the player is to slam into it at the players discretion. On impact both boxes are to bounce off each other and move in different directions.

    I have the player movement set, "just" the collision and bounce is left.

    Now this I would like to do without behaviours but I cant find anything that could help me out, altough I am still searching.

    Rotations arent necessary for me, only direction.

    I really wish there was some explanation, Im begining to dislike the idea of having behaviours that are quite limited in their functionality in regards to custom events.

  • Well, Like I said, the above expression will get the angle between the objects, to get a good bounce you will have to use that angle and the movement angle of the two objects (probably using the speed as well)..

  • You can probably find something in one of my posts.

    The first thing is to detect the collision which is simple enough using the "is overlapping" condition. Next you need to get the objects to not overlap. One way to do that is to move the object backward till it's no longer overlapping, another is to push out in the closest direction which could either be done with some creative checking the around the sprite or using the Separating Axis Theorem (SAT) algorithm. The final thing to do is the actual bounce, usually that requires the normal or angle of the edge where the two objects meet. SAT can provide this or you can treat the objects as circles and utilize the angle between them as LittleStain said.

  • LittleStain


    Thanks for the reply.

    I took some time to think this over.

    The first thing is to detect the collision which is simple enough using the "is overlapping" condition.

    Well to be honest the collision detection is not that simple in my situation I dont think (surely not for me).

    I can detect for right and left no problem, by setting up a variable that switches depending on which arrow was pressed last.

    But for the up and down movement its different, I have a different mechanic and cannot do so.

    I am using self.Y+[other variables]*dt to define the movement, and it seems I cannot marry in the vector movements to be able to have the angle direction.

    I was wondering if there is an easy way to check which side of the sprite was hit (or which side is overlapping), left, right, up, down (in another program I used this was already implemented in the system as events) and then perform and event/action accordingly. I have tried to use image points, but Im not sure how to handle the image points on the corners as they would be overlapped from 2 sides, and I really dont want to attach sensors all around manually, but will do so in the end if Im forced.

    Additionally, I am using a formula for the speed, thus your example in which the system checks for the angle the player is moving is not appropriate for me.

    Also I dont mean to spam, but Ive created another thread with a more elaborate question regarding my problem, and I would appreciate if you could check it out:

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)