Page 1 of 1
Offset origin How?
Posted: Thu Dec 11, 2003 5:49 am
by Vic Marrow
I got a Sherman tank moving, turning, stopping. The turrent rotates and fires. I even figured out how to drive it. (big deal for me

) What I would like to do is glue a tank crew to it I know when you use "glue" You glue one enity origin to another enity origin. How would you offset an origin. I mean what would the script statement look like?
Something like this maybe?
$my_ai.origin glue $tank.origin offset (0 0 0)
I know I will have to play with the numbers (x y z)
I looked through some scripts but got lost as usual.
Thanks for your help!
Posted: Thu Dec 11, 2003 6:40 am
by jv_map
The regular way to do this is by using 'bind' instead of 'glue'. However, when you bind something to a vehicle as a result it will refuse to move
Instead, you could make a script bind thread. However as you need to account for the rotation of the vehicle this thread would turn out to become overly complicated. In this case it's probably best to use a system of script_origins and let mohaa do the maths for you:
Code: Select all
glueguytotank local.tank local.offset:
local.org1 = spawn script_origin
local.org1 thread glueto local.tank
local.org2 = spawn script_origin
local.org2 = local.tank.origin + local.offset
local.org2 bind local.org1
self thread glueto local.org2
end
glueto local.other:
while(self && local.other)
{
self.origin = local.other.origin
self.angles = local.other.angles
waitframe
}
end
offset
Posted: Thu Dec 11, 2003 9:51 am
by tltrude
Just leave out the word "offset".
$my_ai.origin glue $tank.origin + ( -32 16 64 )
Posted: Thu Dec 11, 2003 10:37 am
by Parts
Here's a script that attaches a player to a Truck. This works fine in Spearhead, not sure about MOHAA.
Uses a level variable to decide when to glue and unglue the player
Code: Select all
AttachToTruck local.Player:
//This model is glued to truck origin
local.PointGluedToTruck = spawn script_model
local.PointGluedToTruck glue $truck1
// This model is where you want the players origin to be.
local.playerPos = spawn script_model
local.playerPos.origin = local.PointGluedToTruck.origin + (0 0 55)
// Bind these two points together so one follows the other around
local.playerPos bind local.PointToAttachPlayerTo
local.Player.origin = local.playerPos.origin
if (level.TruckMoving == 1)
{
local.Player glue local.playerPos
while (level.TruckMoving == 1)
{
wait 1
}
local.Player unglue
}
end
Posted: Thu Dec 11, 2003 7:57 pm
by Vic Marrow
I tried these and had problems (of course) Probely didn't set'em up right. I tried your way jv_map. I set it up like this:
Code: Select all
glueguytotank local.tank local.offset:
local.tank = $Sherman
local.org1 = spawn script_origin
local.org1 thread glueto local.tank
local.offset = ( -8 -14.5 112)
local.org2 = spawn script_origin
local.org2 = local.tank.origin + local.offset
local.org2 bind local.org1
self thread glueto local.org2
end
glueto local.other:
while(self && local.other)
{
self.origin = local.other.origin
self.angles = local.other.angles
waitframe
}
end
My console gave me an error that said self.origin = local.other.origin Can not cast 'vector to listener'
And thats the same error message I get when I try tltrude's way. except I had add brackets around $tank.origin + ( -32 16 64 ) it wouldent parse with out them like this:
Code: Select all
$tankcdr.origin glue ($Sherman.origin + ( -8 -14.5 112))
Parts your way kinda looks like jv_maps way. But I'm not sure how to plug in my variables. Like I know $truck would be replaced by $Sherman and my numbers would replace the numbers, but what about level.TruckMoving? Is that a thread from somewhere else? and where does local.PointToAttachPlayerTo come from? I tried messing with this and sometimes it woulden't parse or I would get the
Can not cast 'vector to listener' or one time the tankcdr was sent to the top of my skybox!
I tried this:
Code: Select all
$tankcdr.origin = ($Sherman.origin + ( -8 -14.5 112))
This put the guy right where I wanted him but the tank woulden't move.
Also what does NIL mean is that a statement that the game can't find or see.
Posted: Thu Dec 11, 2003 8:55 pm
by jv_map
Vic Marrow wrote:My console gave me an error that said self.origin = local.other.origin Can not cast 'vector to listener'.
For debugging it is vital that you mention where the ^ is placed in the error message. This symbol indicates where the error occured.
Posted: Thu Dec 11, 2003 9:23 pm
by Vic Marrow
Sorry
self.origin = local.other.origin
self.origin = local.other^
^~^~^Script Error: Cannot cast 'vector' to listener
self.origin = local.other.origin
self^
^~^~^Script Error: Cannot cast 'NIL' to vector
self.angles = local.other.angles
self.angles = local.other^
^~^~^Script Error: Cannot cast 'vector' to listener
self.angles = local.other.angles
self^
^~^~^Script Error: Cannot cast 'NIL' to vector
and this message keeps repeating over and over
Posted: Fri Dec 12, 2003 8:42 am
by Vic Marrow
I got it to work like this:
Code: Select all
$tankcdr.origin = $Sherman.origin + ( -8 -14.5 80)
$tankcdr bind $Sherman
Looks cool to see the Sherman drive by with the commander up in his coupla.
But it still needs some work. I have him exit the tank like this:
Code: Select all
$nazi_tank waittill death
$tankcdr unbind
$tankcdr physics_on
$tankcdr anim tank_exit_1
$tankcdr waittill animdone
$tankcdr runto $wp1
When he goes into the runto command, instead of jumping down to the ground he runs on imangery plane like a straight line was drawn from the turrent to the waypoint. Most of the way to the waypoint he is running in mid-air. (Gotta fix that) Also when he's up in the tank turrent and the gun fires the tank rocks but he dosen't. I tried the physics_off command for him but this didn't help. Another thing I would like to do is have his angles the same as the turrents angles (not the tank base. The turrent will rotate but he does not) It sounds easy but the tank base and the turrent are 2 different tik files. In radient all you see is the Sherman base and the game spawns the turrent. My tanks targetname is $Sherman but how do you call out the turrent. I know when you make the main gun traverse aim and fire its called like this:
TankFire:
local.gun1 = self QueryTurretSlotEntity 0
local.gun1 setAimTarget $nazi_tank
local.gun1 waittill ontarget
local.gun1 startfiring
end
When you call the thread self is $Sherman. So I tried:
$tankcdr.angles = $Sherman.QueryTurretSlotEntity0.angles
But it didn't work. I got to figure how to or whats the targetname for the turrent. Also I noticed in radiant when you bring up the turrent and push the animate button the commander hatch opens and I looked in the files and theres an animation for hatch_open Just got to figure out how to use it. Man this is fun but I feel dizzy and I think I better go to bed now.
$tankcdr
Posted: Fri Dec 12, 2003 8:51 am
by tltrude
I think ther is a command:
$tankcdr droptofloor
Or something like that.