Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: PolyMad on September 29, 2018, 01:56:08 AM

Title: Problem with COLLISION EVENT
Post by: PolyMad on September 29, 2018, 01:56:08 AM
I want to pass onto another state when COLLISION EVENT register that my object has collided.
To do this, I added a transition to send it forward in case of collision.
As it's about a wheel touching the ground and I want to add torque only when the wheel is in contact, I am using COLLISION STAY, but the action is not moving forward.
It doesn't even FINISH and get back to the initial state. What the???
What am I doing wrong here?
Title: Re: Problem with COLLISION EVENT
Post by: PolyMad on September 29, 2018, 02:02:13 AM
Found a COLLISION EVENT PLUS in the Ecosystem, but it seems it only allows global transitions??? Why?
Title: Re: Problem with COLLISION EVENT
Post by: PolyMad on September 29, 2018, 03:17:14 AM
I am trying to use the GET COLLISION INFO now, but with no luck.
I try to get the SPEED in example, in the hope that it gets when the impact happens, but it doesn't detect it.

I am wondering: is the only way to do this to create another object, a trigger, that when is in contact will allow the state to proceed by using COLLISION EVENT?
Even though I still can't understand why the action is not moving away from that state at all.

I would like so much to avoid adding another collider for each wheel... that doesn't make much sense.
Do we have a simple flag in Unity for an object that is actually touching another object? That would be all I need to make this work.
Title: Re: Problem with COLLISION EVENT
Post by: djaydino on September 29, 2018, 05:55:36 AM
Hi.
Maybe what you are looking for is "Get Wheel Collider Is Grounded"

Searh for "wheelcollider" maybe there are some other actions that are useful for you :)
Title: Re: Problem with COLLISION EVENT
Post by: PolyMad on September 29, 2018, 08:58:38 AM
I don't use the wheel collider, for many reasons... I use cylinder meshes.
Title: Re: Problem with COLLISION EVENT
Post by: djaydino on September 29, 2018, 09:25:49 AM
Hi.
Ah then its best to use a raycast
Title: Re: Problem with COLLISION EVENT
Post by: PolyMad on September 29, 2018, 09:39:57 AM
You are telling me there's not a simple flag saying that an object is touching another object???
It doesn't make any sense to shoot rays when PhysXhas all these info ready.

https://docs.unity3d.com/ScriptReference/Collision.html
https://docs.unity3d.com/ScriptReference/Collision-gameObject.html

If collisiongameobject <> "" then add torque!
Title: Re: Problem with COLLISION EVENT
Post by: djaydino on September 29, 2018, 11:24:02 AM
Hi.
If your object is rotation and you use gravity and stuff it will not be reliable.
you can also use a trigger just below the wheel bottom.
Title: Re: Problem with COLLISION EVENT
Post by: PolyMad on September 29, 2018, 01:26:07 PM
Sorry, but how can it not be reliable??? When the wheel impacts the terrain, it ALWAYS bounces, so it always records the hit.
Title: Re: Problem with COLLISION EVENT
Post by: djaydino on October 01, 2018, 01:53:56 AM
Hi.
I probably misunderstood your setup.

I can see on the picture tho that the tag is empty, try changing that to the same tag as the ground.

or maybe there is no rigidbody :)
Title: Re: Problem with COLLISION EVENT
Post by: PolyMad on October 01, 2018, 08:08:51 AM
I checked that, and for what I understand no tag means anything, that's why I didn't proceed to add tags etc.
Title: Re: Problem with COLLISION EVENT
Post by: djaydino on October 01, 2018, 09:57:40 AM
Hi.
can you check these? (quoted from a unity answer)
Quote
Missing RigidBody (the most common).
At least one of the GameObjects involved needs to have a Rigid Body (check if at least one of them have a RigidBody attached and does not have the "Is Kinematic" checked)

Missing tag.
 The GameObject from collision does not have a "Collider" tag (try to remove the if statement to test it) (to compare tags, use collider.gameObject.CompareTag("Collider"), it has a better performance)

Undetectable collision.
The physics Layer Collision Matrix is set to not detect collision between the layers the objects are (enter Edit > Project > Phisics and check if the encounter of the layer of both GameObjects are checked inside Layer Collision Matrix)

Wrong Collider configuration.
One or both of the GameObjects have a small/wrong placed or absent Collider (check if they both have a Collider component and if their size are correct)