Game Development Community

Im stuck need to control player and vehicle at the same time !

by Billy L · in Torque Game Engine · 02/07/2003 (1:22 am) · 20 replies

Hi all !

Im stuck !
I need badly to control a vehicle and shoot with the player
at the same time !
Like to stear the vehicle with keys and move the upper part
of the players body to aim and shoot !
anybody got a clue ???

I can control either the vehicle or the player but need to control
both !

My english is not good ,sorry !

Greetings
Billy

#1
02/07/2003 (11:25 am)
The player can be set to control another object, an example of this is when you mount a vehicle... your still in control of the player, but the player is passing control moves onto the vehicle. If you look at the player.cc file, in the processTick() method, starting around line 1051, you can see what's going on. You could easily change this code to split up the input moves however you like.
#2
02/08/2003 (12:39 am)
Hi Tim !

Thx for the reply ,i dig in to the code hope i find it !
Its a major thing in my game so i really must have this function !
And im no super coder !!!!

Greetings
Billy
#3
02/08/2003 (9:15 am)
What you need to do with processTick is forward the Move to the player as well as the vehicle. Only one object can be the 'control object' at one time, and that object is what gets the Move passed to it. All you'd need to do is determine which (player or vehicle) you wanted to be the control object, then in the code for it, forward the moves to the other object by calling processTick( Move * ) on that object.
#4
02/09/2003 (1:32 am)
HI !

I got it working with your ideas guys !

But !!!
I made a legvehicle , i took most parts from the player block !
It works but still having problems !

The function i need now !
- is to block so the lower parts of the body dont rotate .
- set a max turning angle on the upper body .
- get the z axis rotation on the player when its mounted to work !

I can do this now
- ride the horse and shoot
- use keys and mouse to stear
- use mouse to aim ( but only sideways )

need moore hints

Billy
#5
02/09/2003 (10:04 am)
Hmmm. I need a bit more information to help you out. Do you want to use the mouse to rotate the player, and the keyboard to move the horse?
#6
02/09/2003 (11:10 am)
the function im after is

move the horse forward and sidestep with keys ( it works now )
but the mouse movement is a tricky one
i want to aim with player and at the same time stear the vehicle ,so if you make a small adjustment you only aim
and if you make a bigger one it stears the vehicle at the same time .

it works now but i want to lock the player movement to maybe
90 deg so its a limited rotating on the upperpart of the body !
and when you reach the limit angle you stear the vehicle moore .

now the player turns around when i move the mouse and stear the vehicle !

Hope this explonation is enoth !

I keep on digging hehe !
#7
02/09/2003 (1:27 pm)
or is it anyway to do this ?

vehicle movement

- forward & backwards ( keys )
- sidestep ( keys )
- mouse button 1 pressed you get the stearing on the mouse
movement.

player movement

- mouse movement turn players upperbody in a limit angle
- mouse button 0 fire

so close to get it work !
#8
02/12/2003 (6:36 am)
the only thing i need now is to limit the yaw rotation on the player when mounted !

I can stop the rotation but not limit it !
Made this in the player.cc to stop it

if (move->yaw){
pMove.yaw = 0 ;
}

hope someone got an idea !
#9
02/12/2003 (1:50 pm)
Have a look at updatemove in player.cc
if I recall correctly, that function restricts head rotation left and right (among other things)


-Ron
#10
02/12/2003 (1:52 pm)
more specificly

if (move->freeLook && ((isMounted() && getMountNode() == 0) || (con && !con->is
FirstPerson())))
      {
         mHead.z = mClampF(mHead.z + y,
                           -mDataBlock->maxFreelookAngle,
                           mDataBlock->maxFreelookAngle);
      }

The above is what TGE uses to limit the head rotating left/right

To make it full 360 (yes, I know you not looking for that. Just posting it as a FYI) replace the above with

mHead.z += y

-Ron
#11
02/13/2003 (10:31 am)
Hi ron !

I tried your example it works but the rotation is not smooth enough !
I want the rotation more like the pitch rotation .
I should aim with a gun so it must be smooth !

I must use something with the mRot.z i tested todo another code
it works smooth and real good but only in one direction
if i only could turn this around !!!
F32 y = move->yaw;
if (y > M_PI) y -= M_PI;
mRot.z = mClampF(mRot.z += y,
mDataBlock->minLookAngleMounted,
mDataBlock->maxLookAngleMounted);



-Billy
#12
02/13/2003 (10:56 am)
turn it around? not following yah
#13
02/13/2003 (11:23 am)
hehe sorry !

When i use it now it turn only to the right.
from 0 to 40 deg right .
so its only a rotation in one direction !

it's something with the mRot.z and the PI , when i use
the mHead it works but not with the mRot.z.

-Billy
#14
08/04/2003 (1:17 pm)
Hey, could you please share the code that allows vertical movement and shooting while mounted at a vehicle? I needed this same thing ... Thanx
#15
08/05/2003 (6:43 am)
Hi Sebastiao

I havent finnished this yet had alot otherthings todo
but i give it a try later !
you have a resourse to stear the vehicle with keys look
at that one its simular to mine !
But they use the vehicle.cc to make the stearing with keys !

-Billy
#16
08/07/2003 (11:19 am)
Yeah, I added the resource to steer with keys, but didn't got the
vertical mouse movement and firing to work. I'm fuddling with Player::processTick but nothing yet =P. Okay dude, Thanx. Any help is welcome.
#17
08/07/2003 (4:25 pm)
Sebastiao

when i made this i made the stearing function in the playerblock
not in the vehicle block thats why i could stear and shoot and the same time !
I got it still working but i must dig alittle bit deeper to get it smoother when i aim left and right only.
othervise it works good !
#18
08/08/2003 (11:26 am)
I got it working Billy, thanx anyway.
#19
09/29/2004 (5:49 pm)
COOL!why not post it as resource?It is very helpful for everyone.thanks
#20
09/29/2004 (5:58 pm)
Wow tyg where did you find this thread :)

I know there are some out there that have this working , my source is on ice othervise
i had released this as a resource !
But time is against me :)