how to replicate solid-like behavior without using solids

0 favourites
  • 5 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • What I'm trying to is to have objects stop moving when they are moving towards each like when two solids hit, but without using the solid behavior.

    This is because I'm trying to have objects like my player character and enemies not be able to pass through each other. I tried just adding solid behavior, but having moving colliding solids was a BAD idea. I used the platform vector x action, which had the player character and the enemy bounce off each other when they collided , but even that had weird results when they bounced off each other too many times.

    So is there anyway to get what I want without using solid behavior, Im sure the overlapping action could help me out, but it's early morning and my brain is kinda fried so hopefully someone can help me with an answer,

    Thanks in advance

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use the while is overlapping condition to move your objects towards the opposite position. See the attached capx.

  • You could try the custom movement behavior's push out action but that doesn't work too great for moving objects.

    One idea is to treat the enemies and player as circles. Then see if they collide if any two of them have a distance between them less than the sum of their radius'. Then the overlap between them would be radius1+radius2-distance. To resolve the collision just move each object half of the overlap away from each other.

    Also you'll want to either set the speed to zero, bounce the objects or only set the velocity in the direction of each other to zero. The last two can be done with the help of a vector projection:

    Speed_at_angle= velocity_x*cos(angle)+velocity_y*sin(angle)

    Then you can eliminate speed in that direction by:

    set velocity_x to velocity_x-Speed_at_angle*cos(angle)

    set velocity_y to velocity_y-Speed_at_angle*sin(angle)

    or to bounce do:

    set velocity_x to velocity_x-K*Speed_at_angle*cos(angle)

    set velocity_y to velocity_y-K*Speed_at_angle*sin(angle)

    Where K is 1 for no bounce to 2 for fully elastic bounce.

    I have an example of it in the first capx in this topic:

    and a more advanced version of the walls can be found here:

    But there are probably other ways.

  • R0J0hound




  • Well these replies have given me some stuff to think about, i'll try them out when i get a chance,

    Thanks for all the help

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