Game Development Community

Moving an object to the player

by Kimberly Unger · in Torque Game Engine · 02/18/2004 (3:36 pm) · 21 replies

We are trying to move a bot from where it is to the player. We are using the "setMoveDestination" fuction and it works just fine except in the Z-coord (vertical).

We also need the destination to change when ever the play changes it position.

Can anyone help out?
Page «Previous 1 2
#1
02/18/2004 (8:07 pm)
What are u tryna do?

you want a bot in the same x,y,z of the player?
or are u trying to make the bot follow the player....like hostages from cs?
#2
02/18/2004 (10:09 pm)
I would like to know it too.
#3
02/19/2004 (9:46 am)
Disclaimer: I'm relatively new to Torque, but I've poked around in the source and scripts a bit.

There is a setMoveObject() (I think that's the right name) script function in one of the AIPlayer.cs files floating around, but that just gets the object's location once, then behaves just like setMoveDestination. No joy there.

There's also an setAimObject function... but this controls facing, not movement. It DOES however, keep track of the object it's aimed at, not just a location.

This leads me to believe there are several ways to do what you want:
1) Schedule a setMove[Object/Destination] event to be called regularly... this will keep the ai running toward the right location, though with a bit of a "lag"

2) A variation on 1)... just get the location of the aimObject over and over again instead. This would have the advantage of not needing to pass in a seperate player object/ID/Tag/whatsis to your script.

3) Change the AIPlayer[.cc/.h] source files, creating a genuine SetMoveObject engine function. This would eliminate the 'lag' of the above method, and would almost certainly be more efficient... It would be compiled rather than interpreted, and wouldn't involve a schedule call at all.

But like I said, I'm new here. Someone else with a better understanding of what's going on could probably come up with a better solution.
#4
02/19/2004 (10:11 am)
What we are doing is having a Bot be moved from where it is on the ground to a vehicle that is flying by. The vehicle can hover but will usually be moving. I have a point in the vehicle that has the 'Tractor' beam emiter and that is where the Bot is to be moved to. Not moving in the vertical (Z Coord) is the biggest issue right now.
#5
02/19/2004 (1:28 pm)
"Not moving in the vertical (Z Coord) is the biggest issue right now."

Is the bot walking, or flying? Is it refusing to climb hills or walk up steps? There is a lot of unknowns here that make it hard to give an educated answer about what might be occuring. It is my understanding that if you send a bot to a location he will climb any hill or steps that are not above the parameters set for the object.

Can you give a little more detail about what the bot is moving "Up" on?(terrain, steps, flying, etc...)
#6
02/19/2004 (1:31 pm)
The Bot normally walks on the ground. The 'tractor' beam will pick it up and move it to the flying vehicle so I guess you'd say the Bot is flying too.
#7
02/19/2004 (1:36 pm)
So the problem lies in getting the beam to "Pick up" the bot and move it into the vehical? Or is it supposed to be hanging inside the beam as it is being moved?
#8
02/19/2004 (1:54 pm)
It Doesn't move up. It does move along the ground until it is under the ship.
#9
02/19/2004 (2:01 pm)
I think the player is in the flying vehicle and a beam is emitting from the vehicle to a point of the ground, so the bot that is moving on the ground should follow the point at the ground and when reached to it the beam will take the bot up to the flying vehicle, right?.
#10
02/19/2004 (2:04 pm)
What we want is to have the Bot move directly to the "emmiter". That is follow the ray from the "emmiter" back to the ship.
#11
02/19/2004 (2:10 pm)
I think you might be confused as to what move to dest does. When you use it, the bot (or whatever) is still subject to gravity and the whole simulation. Using movetodest to "fly into the air" will not work. Your tractor beam will probably have to have a physical zone (modifies grav/etc) to make the bot move into the air.
#12
02/19/2004 (2:15 pm)
Where can I find some exammples of this physical zone in use? I mean scripts and such.
#13
02/19/2004 (2:32 pm)
If you want a quick hack for this, then once the bot reaches the beam location you could mount the bot to the vehical with a negative Z axis offset that puts it below the vehical and makes it appear to hang suspended in the beam. That is certainly doable immediately if you have a mount point on the vehical in question.
#14
02/19/2004 (2:40 pm)
Thanks but we have the time to do it with out a Hack.
#15
02/19/2004 (2:46 pm)
You know, i dont know if there are any examples! It is in the world editor under environment I think. Add one, set the size and then I think there is a section that defaults to 1 1 1 which are the modifications (is multiplied in the engine code). I'm not sure how you would get it to attatch to a vehicle though. You might want to look at some of the mods for tribes 2 actually (jumppads). Not sure if any of the mods had a tractor beam deal attatched to a vehicle.

good luck!

-s
#16
02/19/2004 (2:50 pm)
"Thanks but we have the time to do it with out a Hack."

Hack is not a bad term, it is just a term. Consider this...

Which is more efficient on engine performance...

A. Mounting a bot to the vehical with a mountpoint and letting existing code control the bot?

B. Writing a new set of additional functions that perform continuous checks and updates to the bot to keep it dragging along with the vehical while the other code sits there uselessly?
#17
02/19/2004 (3:02 pm)
Didn't mean to upset you. I use the turm "hack" to mean a quick fix using methods not inteded for this function.

What I'd rather do is modifiy the engine code, if needed, so that the Z-Coord is taken into consideration.

If the physical zone mods have not be used before, 'so be it'. New teritory to explore.
#18
02/19/2004 (3:18 pm)
Not upset at all, I just wanted to clarify that hack may not have been the best term to use there for what I had intended. I myself prefer to always use the correct method for coding, no matter how simple or complicated. Judging by your response, I can assume you feel the same way.

:-)
#19
03/05/2004 (12:57 pm)
Can anyone tell me why the getAIMove does not move the object in the Z coordinate? An what are the possible effects of changing the code to enable Z coordinate movement.
#20
03/07/2004 (12:17 pm)
Because the AIPlayer moves just like a normal player, except with the AI code generating moves instead of a player across a network connection.

If you want the AIPlayer to fly up to a given position, either add jetpack support ;), or try making it follow a path - perhaps add a special case of movement to ShapeBase so that the player can be switched over to it temporarily.

Getting it to move around in Z using Moves is just asking for trouble. You should do it with another mechanism.

Heck, maybe switch gravity on it temporarily so it floats up.
Page «Previous 1 2