playMaker

Author Topic: 2D collision not working  (Read 3090 times)

Kyani

  • Playmaker Newbie
  • *
  • Posts: 7
2D collision not working
« on: August 21, 2014, 08:48:56 AM »
Hi, I am just starting out with Unity and Playmaker.

I have created a platform that I can move on the x axis using translate. I have circle prefabs spawning that bounce off this platform no problem.
I also have a wall which the circles will also bounce off.
My problem is that I want the platform to stop when it hits the wall, however it just goes through.
The wall and platform both have 2D box colliders on them, If I add a 2D rigidbody to the platform it will work, however I don't want to do this as when the circle prefabs hit, they will move it. If I tick "Is Kinematic" the Trigger and Collider events are not firing.
Is there a way to achieve this without a 2D rigidbody?
Thanks

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: 2D collision not working
« Reply #1 on: August 21, 2014, 09:22:18 AM »
Collisions and triggers work fine with Rigidbody2D's. You may have to change how you're setup just a bit, and make sure you use the 2D equivalents of the Collision/trigger action.

I would put a Slider Joint 2D on the platform and use the built in Motor & Limits for it. That's basically what its made for.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Kyani

  • Playmaker Newbie
  • *
  • Posts: 7
Re: 2D collision not working
« Reply #2 on: August 21, 2014, 05:45:26 PM »
Hi, Thanks for the reply.
I know collisions work fine with the Rigidbody 2D, but when I have the Rigidbody2D on, the wall or platform will move when they collide.
I want the platform only moving on my left and right key press (which it is doing) and when they collide, I want the platform to stop against the wall.
With the Rigidbody 2D on, the platform pushes the wall rather than stopping against it. Is there a setting I am missing somewhere?
Thanks

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: 2D collision not working
« Reply #3 on: August 21, 2014, 05:53:11 PM »
The Slider Joint 2D Should fix those problems, have you tried it?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Kyani

  • Playmaker Newbie
  • *
  • Posts: 7
Re: 2D collision not working
« Reply #4 on: August 21, 2014, 06:03:34 PM »
Thanks, Will give that a try today :)

Kyani

  • Playmaker Newbie
  • *
  • Posts: 7
Re: 2D collision not working
« Reply #5 on: August 21, 2014, 08:22:35 PM »
I have had a play with the slider joint, which will slide along and collide with the wall, however, I need to be able to manually move the platform from side to side with key presses. Also, I want the platform to move to fixed positions, rather than sliding along.
thanks
« Last Edit: August 21, 2014, 09:01:27 PM by Kyani »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: 2D collision not working
« Reply #6 on: August 21, 2014, 09:14:07 PM »
You can use the internal motor of the joint, its made for that. Just make a Get Axis action and feed that into the joint component with this action:

http://hutonggames.com/playmakerforum/index.php?topic=7773.0
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Kyani

  • Playmaker Newbie
  • *
  • Posts: 7
Re: 2D collision not working
« Reply #7 on: August 22, 2014, 12:11:01 AM »
Cool, thanks, Im getting there now! Just have to work out how to make the platform only move to 3 or 4 fixed positions.