How to get distance between you and target

hey.. i decided to post it because i have been like a whole day trying to calculate the distance between your actor and the targer to get the distance with the formula but then i found out theres an opcode that does it automatically so here it is, just in case someone else needs it :)

0104: actor $PLAYER_ACTOR near_actor 0@ radius  RANGE_X  RANGE_Y  RANGE_Z sphere  0

so if i want to check if someone is at the distance of 10.0 from me i would do this

Code:
if
 0104: actor $PLAYER_ACTOR near_actor 0@ radius  10.0  10.0  10.0 sphere  0
then
...

hope it is usefull for someone as it was hard to find for me. xd


where 0@ is the actor target
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
MY_POS = 1@ 2@ 3@
TARGET_POS = 4@ 5@ 6@

050A: 7@ = distance_between_XYZ 1@ 2@ 3@ and_XYZ 4@ 5@ 6@

7@ is now the distance between you and the target position.

if
7@ < 50.0 // if distance is smaller than 50.0
then

end
 

downloadstuff

Active member
Joined
Apr 4, 2015
Messages
82
Reaction score
0
Opcode.eXe link said:
MY_POS = 1@ 2@ 3@
TARGET_POS = 4@ 5@ 6@

050A: 7@ = distance_between_XYZ 1@ 2@ 3@ and_XYZ 4@ 5@ 6@

7@ is now the distance between you and the target position.

if
7@ < 50.0 // if distance is smaller than 50.0
then

end

thanks didnt know that one.
 

MrChristmas

Expert
Joined
Jul 29, 2014
Messages
563
Reaction score
26
Do not learn Cleo, it won't take you anywhere... If you want to start learning, then start from C++, C# or even Turbo C it will take you further and give you more possibilities.

[member=13605]Paul159[/member]
[member=39749]The gay Gamer[/member]
[member=5978]bye[/member]
 

Child_

Active member
Joined
May 9, 2015
Messages
115
Reaction score
0
Thanks for the advice, Perhaps now I would stop fucking my mind and concentrate on C#
 
Top