playMaker

Author Topic: Easy way to turn on and off collision between 4 objects?  (Read 433 times)

Zswag

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Easy way to turn on and off collision between 4 objects?
« on: April 05, 2019, 07:40:24 AM »
I have 4 game objects, id like to turn collision on and off for; during playtime. Is there any way i can do this with the playmaker actions?

Im pretty sure i can do it with layers, but i need the ability to do so during playtime.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4620
    • View Profile
    • jinxtergames
Re: Easy way to turn on and off collision between 4 objects?
« Reply #1 on: April 05, 2019, 04:21:00 PM »
Hi,
You can find some actions for this on the Ecosystem, search for 'enable collider'


tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 742
    • View Profile
Re: Easy way to turn on and off collision between 4 objects?
« Reply #2 on: April 06, 2019, 02:11:12 AM »
You can also change layers during runtime, but I am not sure what effect that would have on performance? I would only change layers IF you need them to hit other things. Otherwise I agree with Djaydino's suggestion.

Zswag

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: Easy way to turn on and off collision between 4 objects?
« Reply #3 on: April 07, 2019, 12:51:45 PM »
Not sure i explained well enough, anyways:

I pretty much have 4 player controllers, that i want all spawn in the same place, and not to collide with eachother until their a sertain distance away from eachotherer. They all spawn in one place, once they are not inside another player they may collide with other players with the same conditions.

So turning of collision inierly wouldnt acomplish what im trying to do, is there any actions that i should be looking at?

Doh

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: Easy way to turn on and off collision between 4 objects?
« Reply #4 on: April 09, 2019, 05:23:39 AM »
You may have some luck with "Set Layer".

You could create a layer called something like "spawn layer" and another maybe "player". Using the collision matrix make it so "spawn layer" cannot collide with itself. Make it so "spawn layer" is their initial layer.

You could place a trigger at the spawn location with an FSM that does something like: "on trigger" exit - "set layer" "player" or if you want to do it by distance that could be done too using "float compare" with "get distance".

You could still run into a problem where two players get to the required distance at the same position and end up colliding early, though you could use "check sphere" at the player's location to make sure they're alone first.
« Last Edit: April 09, 2019, 05:25:58 AM by Doh »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4620
    • View Profile
    • jinxtergames
Re: Easy way to turn on and off collision between 4 objects?
« Reply #5 on: April 09, 2019, 05:34:22 AM »
Hi.
There is an action called : PhysicsIgnoreCollision

You can use those 3x (1 for each player)

Then use Trigger exit actions to know if you are not inside a player (use different tags for each player)
do this with 3 fsms, one for each player.

Once players are apart turn collision on with the same action.

You might need to add a child object with a collider (set to trigger) on the players as trigger might also be ignored.