Post your scripting questions / solutions here
Moderator: Moderators
fuhrer
Captain
Posts: 253 Joined: Sun Mar 14, 2004 3:36 am
Post
by fuhrer » Thu Apr 22, 2004 2:58 pm
im trying to measure how far away a ball is from a waypoint (height only) as the waypoint stays in one position ( on the ground) and ther ball moves on all 3 axis.
when ive tried to do it im assumin its measuring the distance between the 2 origins in a straight line..
what i need is to have it only measure the distance in height. (Z axis?)
Code: Select all
$ball moveDown (vector_length ($ball.origin - $ball_stop.origin))
ive tried...
Code: Select all
$ball moveDown (vector_length ($ball.origin[2] - $ball_stop.origin[2]))
must be doing something wrong, please help.
lizardkid
Windows Zealot
Posts: 3672 Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT
Post
by lizardkid » Thu Apr 22, 2004 3:56 pm
you could do
and use local.height to comapre to the node. ignoring the two othr axis.
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
tltrude
Chuck Norris
Posts: 4774 Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:
Post
by tltrude » Thu Apr 22, 2004 4:40 pm
If you want to see what the value is, just print it to the screen.
iprintln (vector_length ($ball.origin - $ball_stop.origin))
Here is something i used.
$ball moveto ( ($ball_target.origin[0]) ( $ball_target.origin[1]) ($ball.origin[2]) )
Notice that the origin of the third number is different from the first two. That keeps it on the ground by not letting the third number change.
Last edited by
tltrude on Thu Apr 22, 2004 4:46 pm, edited 2 times in total.
Tom Trude,
lizardkid
Windows Zealot
Posts: 3672 Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT
Post
by lizardkid » Thu Apr 22, 2004 4:44 pm
you can print variables in MOHScript? cool.
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
jv_map
Site Admin
Posts: 6521 Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:
Post
by jv_map » Fri Apr 23, 2004 1:16 pm
Actually, I think the most straightforward way to do it is the following:
Code: Select all
// say you have two ents $a and $b with some origin
local.origin_a = $a.origin
local.origin_b = $b.origin
// the vector from a to b now is
local.vec_ab = local.origin_b - local.origin_a
// as you only want to measure the horizontal distance,
// let's set the vertical component to 0 :)
local.vec_ab[2] = 0
// now calc the distance :)
local.distance = vector_length local.vec_ab
tltrude
Chuck Norris
Posts: 4774 Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:
Post
by tltrude » Fri Apr 23, 2004 8:35 pm
There is a command that drops entities to the ground. I'm not sure if it will work for a script_object.
droptofloor( [ Float maxRange ] ) - drops the entity to the ground, if maxRange is not specified, 8192 is used.
Tom Trude,