Game Development Community

Mounting and controls

by Stephen · in Torque Game Engine · 03/23/2005 (12:13 pm) · 6 replies

I have posted this thread a few days ago. I have got those questions answered, thanks guys. But now I have a few more questions that have to do with mounting and the controls.

Ok, I can spawn a horse in-game like a bot. I want to make a function that when you touch the horse, you mount the horse and then it changes the controls. Then I need a function to unmount the horse and to change the controls back to defaults.

I have mounted the horse by using this command in the console. "%horse.mountObject(%player, 1);" then once I mount the horse I then type this command in the console "%player.client.setControlObject(%horse);" to control the horse. But I need some functions to do that for me instead of typing those commands in the console.

Right now I have made a few function to spawn the horse in-game and change the controls. Like if I press "ctrl+h" it will change the controls and if I press "ctrl+l" it will spawn the horse. But like I said before I need some functions to mount and unmount the horse and to change the controls.

Keep in mind that I'm using the horse as a example.

Thanks
Stephen

#1
03/23/2005 (1:04 pm)
Define an onCollision method on either the horse or the player's datablock. The engine will call that when a collision occurs, and inform the objects involved with it.
#2
03/23/2005 (2:48 pm)
Could you show me how the function would go.

Thanks
#3
03/24/2005 (5:01 pm)
Can someone please help me! I really need help!

Thanks
#4
03/28/2005 (9:12 am)
I'm just a humble graphics grunt but have you taken a look at the vehicle .cs files that came with the demo?

Might not be exactly what you're looking for but it might give you a pointer in the right direction. I've done a lot of hack-n-slash coding recently using this method.

Sorry I can't help ya more.

cheers,
k
#5
04/01/2005 (11:16 am)
Exactly Katrina.

What you are making is in effect a vehicle. Duplicate the mounting code from there.

As far as custom controls, my game requires multiple sets of keybinds for each vehicle type (air, ground, water, grunt). As each type of vehicle (or lack there of) is mounted/unmounted, I swap the keybinds wholesale.

This permits players to double-bind keys which I have found makes for happy FPSer's since they dont have to remap the entire keyboard.
#6
04/01/2005 (1:08 pm)
Alright.

function myHorseDatablockOrClassName::onCollision(%this,%obj,%col) 
{
//%this is the datablock

//%obj is the horse instance

//%col is the object that is colliding with us
}