Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: ermak on June 02, 2015, 02:54:33 PM
-
Hello,
(http://oi61.tinypic.com/161lrap.jpg)
(http://oi57.tinypic.com/4lfvc0.jpg)
I want "Raycast Direction" to point at Vector3 Target Object.
I am not sure where exactly is the problem... maybe "Direction" is correct, but angle
is not the same as target object.
With "Debug Line" action everything wotking fine.
(http://oi62.tinypic.com/28l53b6.jpg)
(http://oi62.tinypic.com/2roglfo.jpg)
How I can make "Raycast Direction" like a "Debug Line"?
-
Raycast wants a Direction and you're giving it a Position.
The direction is (enemyPosition - playerPosition).normalized. You can get both positions, subtract one from the other. Normalize it, then input that.
-
(http://oi60.tinypic.com/30x7wp2.jpg)
Hello,
It works! Thanks!
But I have one question more. Without "Vector3 Normalize" action working too.
Normalize must be used or it's optional?
-
When normalized, a vector keeps its direction but the magnitude is 1. So the result is like 0.2, 0.2, 0.6 or something whereas before normalization it may have been 20.0, 20.0, 60.0.
Vectors can be very tricky. If you are working with them I would recommend reading a bit about how they work and what you can do with them. It takes some getting used to if you didn't study them in math.
http://docs.unity3d.com/ScriptReference/Vector3.Normalize.html