playMaker

Author Topic: Collision detection without a Rigidbody [SOLVED]  (Read 6793 times)

MadboyJames

  • Playmaker Newbie
  • *
  • Posts: 18
  • Str: 9/ Dex:11/ Con:10/ Int:13/ Wis: 12/ Cha: 12
Collision detection without a Rigidbody [SOLVED]
« on: December 14, 2017, 07:14:05 PM »
Hi, I'm new to Playmaker and I'm struggling with making my player (who has a rigidbody) know when they have hit a wall (which has a Box Collider2D).
What I want is when the player character hits a wall, it does a "wall push" animation. This does nothing to the wall, or exert any force of any kind. I just need to figure out how to know when the player has collided with the terrain from the left or right.
Any help would be appreciated!
« Last Edit: January 03, 2018, 01:29:33 PM by MadboyJames »
Inexperience is just the beginning of greatness.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Collision detection without a Rigidbody
« Reply #1 on: December 15, 2017, 12:54:19 AM »
You need to use rigidbody, but omit any physics simation from happening. You need to set the wall rigidbody to kinematic with simulated full kinematic contacts and enabled isTrigger. What type of rigid body player has?
Available for Playmaker work

MadboyJames

  • Playmaker Newbie
  • *
  • Posts: 18
  • Str: 9/ Dex:11/ Con:10/ Int:13/ Wis: 12/ Cha: 12
Re: Collision detection without a Rigidbody
« Reply #2 on: December 15, 2017, 02:37:08 AM »
The player has a Dynamic Rigidbody2D with continuous collision detection. So I need to give the terrain a Rigidbody2D and take all of the physics-ness away from it? I was hoping there was another way because rigidbodies, dynamic or kinematic, are resource heavy (from what I understand). I suppose that's easy enough to do though.
Inexperience is just the beginning of greatness.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Collision detection without a Rigidbody
« Reply #3 on: December 15, 2017, 03:00:45 AM »
Check this out:

https://docs.unity3d.com/560/Documentation/Manual/CollidersOverview.html

below you have a chart of interactions. Check it out, i have some work to do now, but i'll explain it later.

Edit: Ok, basically, if you have dynamic rigidbody for the player, for the terrain you need to use kinematic rigidbody, it reacts to your collider, but it receives no force, friction, or other physical properties involved in the physical simulation, i.e. it can be moved only with transform property manipulation.
« Last Edit: December 15, 2017, 04:14:34 AM by krmko »
Available for Playmaker work

MadboyJames

  • Playmaker Newbie
  • *
  • Posts: 18
  • Str: 9/ Dex:11/ Con:10/ Int:13/ Wis: 12/ Cha: 12
Re: Collision detection without a Rigidbody
« Reply #4 on: December 15, 2017, 01:43:34 PM »
Okay, So I have a kinematic Rigidbody2D my terrain (which is a tilemap), and I am using the "Get Collision2D Info" FSM Action. I have it so the collision info is put into various variables. The problem is that none of them even get get populated. I still don't think the collision is being detected. I'll be playing around with it more, and I'll post an update if I fix it, but huh, I would've thought that would work.
Inexperience is just the beginning of greatness.

MadboyJames

  • Playmaker Newbie
  • *
  • Posts: 18
  • Str: 9/ Dex:11/ Con:10/ Int:13/ Wis: 12/ Cha: 12
Re: Collision detection without a Rigidbody
« Reply #5 on: December 15, 2017, 02:01:53 PM »
Okay, So my problem was I needed a "Collision2D Event" before I could get the info. My next problem is that when I look at the collision points normal, it's telling which side of the terrain I'm colliding with, rather than what side of the player I'm colliding with. Additionally, with the "Collision2D Event", there are options for On Collision Enter, and On Collision stay, I think want the On Collision Enter, but only when X:-1 or X:1 has been hit. Of course I am not sure of what the best practice is in such scenarios, so I could be wanting something completely different.

Edit:
I was looking at the "Character Controller" component, and It looks like that would allow me to do what I want to do in PlayMaker, but much of the code for movement applies force to the Rigidbody2D, which I cannot have in tandem with a Character Controller. Can the Character Controller be affected in the same ways as the Rigidbody?

« Last Edit: December 15, 2017, 03:56:39 PM by MadboyJames »
Inexperience is just the beginning of greatness.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Collision detection without a Rigidbody
« Reply #6 on: December 15, 2017, 03:27:15 PM »
To be honest, someone else would need to help you with character controller, i never used it. As far as i have seen, api for cc says this:

A CharacterController allows you to easily do movement constrained by collisions without having to deal with a rigidbody.

A CharacterController is not affected by forces and will only move when you call the Move funtion. It will then carry out the movement but be constrained by collisions.
Available for Playmaker work

MadboyJames

  • Playmaker Newbie
  • *
  • Posts: 18
  • Str: 9/ Dex:11/ Con:10/ Int:13/ Wis: 12/ Cha: 12
Re: Collision detection without a Rigidbody
« Reply #7 on: December 15, 2017, 03:55:50 PM »
Yeah that's why I don't really want to use it. Do you know of any other way to get collision-side detection, or detection flags without using a character controller? If there is no easy solution I'll see if I can script it myself, but I'd prefer to use the actions that are part of playmaker.
Inexperience is just the beginning of greatness.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Collision detection without a Rigidbody
« Reply #8 on: December 15, 2017, 04:37:02 PM »
Do you need physics in the game at all or is everything simulated?
Available for Playmaker work

MadboyJames

  • Playmaker Newbie
  • *
  • Posts: 18
  • Str: 9/ Dex:11/ Con:10/ Int:13/ Wis: 12/ Cha: 12
Re: Collision detection without a Rigidbody
« Reply #9 on: December 15, 2017, 05:16:28 PM »
I planned on using physics to make movement easier to code, I am not married to the idea though. It's fast paced platformer, so I could get the "feel" of the game either way. My impression was that using the physics engine would be easier than not. That impression could be wrong.
Inexperience is just the beginning of greatness.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Collision detection without a Rigidbody
« Reply #10 on: December 15, 2017, 06:05:36 PM »
No need for that, i'm running everything in iskinematc simulated and it works fine for me, collision and the rest of the stuff. Since it's a platformer, i don't really think you need physics at all. Even if you do for some stuff, you can easily imitate physical reaction the other way. Jumping without physics would be done with animate transform float etc...
« Last Edit: December 16, 2017, 05:14:00 AM by krmko »
Available for Playmaker work

MadboyJames

  • Playmaker Newbie
  • *
  • Posts: 18
  • Str: 9/ Dex:11/ Con:10/ Int:13/ Wis: 12/ Cha: 12
Re: Collision detection without a Rigidbody
« Reply #11 on: December 15, 2017, 09:34:39 PM »
Alrighty, Thanks! I'll go reform what I have see if it works. :)
Inexperience is just the beginning of greatness.