Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: tcmeric on May 24, 2017, 01:22:39 PM
-
Do we already have an action to get the direction and distance between two objects (without raycasting) ? I couldnt see one.
https://docs.unity3d.com/Manual/DirectionDistanceFromOneObjectToAnother.html
If not, I will write one because I need it. But if we have one, better not to write another. Thanks!
-
Hi,
For the 'distance' i think "get distance2" (on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181)) is what you are looking for.
and for the direction maybe "Get Angle To Target" (standard action) , "Transform Direction Advanced" (Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181)) , "Get Delta Angle" , "Get Signed Angle To Target" :)
-
Hi, thanks for the help! In the end, none were quite right to get the direction between two game objects in a vector 3 (with possible normalization), aka heading.
I ended up writing my own action. Attached.
This action calculates the direction between two gameobjects (source and target) and gives a vector 3 direction. If you choose normalization, it also calculates the distance (magnitude) and normalizes the direction to give a "heading". This could be used to steer/point one gameobject towards another. The normalization has a separate toggle because it take an extra calculation to do it. Therefore if you don't need it, untoggle it.
You may not need the distance/ un-normalized direction if you are using the normalize direction (heading), but I gave the variable outputs anyways, since they are already being calculated (you might as well get access to them, in case you want to use them elsewhere).
-
Hi,
Maybe it is a good idea to also add a possibility to add Vector 3 Values instead of gameobjects, like in some other actions (like in "Get Distance2")
-
I ended up writing my own action. Attached.
I'm just getting...
error CS0234: The type or namespace name `AI' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?
What am I doing wrong?
-
It was using unity.ai . Its unnecessary, so I removed that line. But not sure why your project wouldnt be able to find it.
Here is the action without that line.
-
Great thanks! After a bit of googling it may be because I'm still using unity 5.4/ Sadly updating completely destroys large parts of my game so after several attempts I've decided to stick with 5.4
-
Get this sucker on Ecosystem! :D
-
Done!