playMaker

Author Topic: Push Object on opposite direction when collide  (Read 94 times)

heavygunner

  • Full Member
  • ***
  • Posts: 210
    • View Profile
Push Object on opposite direction when collide
« on: March 31, 2020, 09:23:06 AM »
Hi !

Let's say one cube is running on ground. When player collided with that Cube, cube should be pushed on opposite direction.
Any idea ?

Thanks

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4968
    • View Profile
    • jinxtergames
Re: Push Object on opposite direction when collide
« Reply #1 on: March 31, 2020, 10:45:50 AM »
Hi.
Maybe something like (for 2D) :

On collision :
Get position x player
get position x cube
float compare if player x less than cube player is on left side (do push right)
if greater then the other direction.