playMaker

Author Topic: Collision with Rigid Bodies  (Read 2408 times)

Threepeasoup

  • Playmaker Newbie
  • *
  • Posts: 7
Collision with Rigid Bodies
« on: February 21, 2013, 06:01:02 PM »
Hey Guys,

Beginner to Playmaker and trying to build a point and click 2d adventure game. I built a point and click system on the x and y axis where a playerObject moves towards where I click (based it on the playmaker example point and move). The problem I have is if the playerObject runs into another object and I don't want it to just pass through. So I added a collision and rigid body to both the player and object. Now the player does collide and not pass through, but it creates this crazy jittering movement when its colliding trying to reach the point where I click.

My questions are:
How to get rid of the jittering movement when two objects meet if possible?

Is there a better way to have a playerObject on click and point movement system to move around an object in 2D?

If possible, how do I have the point and click movement system stop moving the playerObject if the playerObject collides into another object?

Any examples or help would greatly be appreciated!

Cheers,
Threepeasoup


greg

  • Junior Playmaker
  • **
  • Posts: 68
Re: Collision with Rigid Bodies
« Reply #1 on: February 22, 2013, 09:47:54 AM »
Here's my idea:
- *create 3 empy game objects, each with a long trigger box, facing forward/front left/front right out from player
- You can check collisions with these to check if anything is: directly in front of the player, just to the forward left of the player, just to the forward right of the player
- when you click give the player a waypoint to move toward/rotate to face
- if anything collides with the "forward trigger box", then check if anything is colliding with the forward right/forward left trigger boxes (if not then it could walk around the object)
- so whichever one doesn't register collision, rotate the game object in that direction until forward trigger box is no longer colliding
- then resume rotating the player toward the waypoint you set to move toward
- IF all 3 triggers collide or a problem occurs (we cant get past easily), then just stop the player moving


So basically if a small object like a tree or rock is in the way of the player, he will walk around it. If a bigger object is in the way he will stop.

* triggers are faster than 3 raycasts every frame, parent these to player

Threepeasoup

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Collision with Rigid Bodies
« Reply #2 on: February 22, 2013, 02:07:36 PM »
Thank you Greg Sergeant, I will try to implement this when I get home.
 
Cheers!