Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: stigma on July 10, 2019, 12:02:10 PM
-
Hello,
Is it possible to detect the collision of a GameObject with any surface?
For example, I want to trigger a script if an object falls into the water.
Thank you
-
Yes. This is very straight forward, but the exact method may vary by what you want to achieve / what you need to work around, etc.
See the manual for Trigger Event: https://hutonggames.fogbugz.com/?W37 (https://hutonggames.fogbugz.com/?W37)
So for example, you could have your water tagged (part of Unity, not Playmaker specifically) as a name ("water" for example) and so when your trigger hit an object with that tag it goes to the next event.
-
it does not work.
I want to push an object in the water and it should float by triggering the script.
-
Collisions are handled by Unity Collider modules; Box Collider, Capsule Collider, Sphere Collider or Mesh Collider
See here: https://docs.unity3d.com/Manual/CollidersOverview.html
I'm having a hard time judging what level you are on and what you need to know or not. I don't know if you need to maybe watch a YouTube tutorial on colliders and setting them to triggers or not.
Basically the collider is the way you can bump in to something. If the object has a collider and a Rigidbody, you will be able to push it (if it's not set to kinematic). You use that regular collider and add a second collider which is a little larger (so it will be hit before the one used to push the object), with the second one set to be a Trigger. This means the second collider is a like a ghost you can pass through, but you can use it to register if something Enters, Exits, or Stays in that trigger.
As mentioned previously, you do this via the Trigger Event action. You set what object you are watching, if it's enter, stay, or exit, and then also (for your case) set what Tag the other colliding object must have to be valid.
-
Hi,
Buoyancy is a very unique physic interaction that is not really supported by default with Unity physics ( apart from the 2d which has an effector for this: https://docs.unity3d.com/Manual/class-BuoyancyEffector2D.html) ,in 3d, you need a lot of work to get there. Which is why I would strongly recommand using an asset for this like:
https://assetstore.unity.com/packages/tools/physics/fast-buoyancy-61079
you also have many more advanced systems as well like:
https://assetstore.unity.com/packages/tools/physics/dynamic-water-physics-2-147990
Bye,
Jean
-
I did something that works by comparing the altitude of the object with the sea.
Is it ok, given that I have a lot of objects that can float?
(http://www.maximages.fr/forums/3D/playmaker/Objet%20eau.jpg)
-
Hi,
It should be ok yes. Make sure to run the profiler to monitor that it doesn't take up too much of your perfs just for this.
Bye,
Jean