Making a Player Fly
by Mark Pumphrey · in Torque Game Engine · 07/15/2005 (3:31 am) · 125 replies
Firstly I would like to state that "Yeah, I have seen the posts about flying but....". They don't work and/or full of bugs. I would like to also state a general request that if you make a post regarding code to edit the original post instead continually trying to 'add' corrections later on making it harder than hell to read. Also, EVERYONE has a copy and paste function of some kind, use it. Saying that "here is some code than will change your life, insert it anywhere" means nothing and helps even less. Ok, enough of that. Has anyone actually made a player fly just like in Tribes?
#62
12/09/2007 (1:36 pm)
Wow thanks! this will be awsome!
#63
12/09/2007 (1:38 pm)
Let me know how it works for you.
#64
12/09/2007 (2:53 pm)
I don't seem to have commands.cs or that other file you said (probally because I'm using a mac). Although I did put the moveMap.bindCmd(keyboard, "t", "commandToServer(\'toggleFly\');", ""); part in client/default.bind.cs (all my other controls are there. I also made a file called commands.cs and put that function there (yes I did put the exec in the game.cs it doesn't seem to work though, any idea?
#65
12/09/2007 (2:59 pm)
Are you sure you don't have a config.cs? It takes priority over default.bind. If you delete config.cs then it will be recreated with the updated information from default.bind next time you open and close torque. Check in the console as well, if the command is firing then you will probably get errors. If there are no errors it is probably not registering your input.
#66
12/09/2007 (4:30 pm)
I don't think Macs get config.cs, I even got a fresh DL and it is not there, I ran a search and I found it in starter.fps and demo. No there are no errors, if it is not registering my input then what should I do?
#67
EDIT: I found an error, client/default.bind.cs Line: 1 - syntax error.
I don't know why it's on line 1 since it is just a comment. any idea?
12/09/2007 (4:42 pm)
I just tried typing "%player.toggleFlying" in the console... No luckEDIT: I found an error, client/default.bind.cs Line: 1 - syntax error.
I don't know why it's on line 1 since it is just a comment. any idea?
#68
12/09/2007 (4:55 pm)
Well it seems to work in starter.fps, but it won't work in tutorial.base... I think maybe that was the problem.
#69
in default.bind.cs find
change all that to
[code]/*
moveMap.bind( keyboard, a, moveleft );
moveMap.bind( keyboard, d, moveright );
moveMap.bind( keyboard, w, moveforward );
moveMap.bind( keyboard, s, movebackward );
moveMap.bind( keyboard, space, jump );
moveMap.bind( mouse, xaxis, yaw );
moveMap.bind( mouse, yaxis, pitch );
*/[code]
If you can still move in your game after doing that then there is something equivalent to config.cs somewhere, if not then you should be getting errors in your console every time you press 't'.
12/09/2007 (4:56 pm)
Config.cs isn't created until torque runs and exits at least once, so it isn't in a fresh DL. It isn't in the same folder as default.bind, it's in the one before it. If indeed there is no config.cs then I have no idea what to do. So if you can't find it this last test will check if it exists somewhere. You need to do this on a copy of torque that has run at least once.in default.bind.cs find
moveMap.bind( keyboard, a, moveleft ); moveMap.bind( keyboard, d, moveright ); moveMap.bind( keyboard, w, moveforward ); moveMap.bind( keyboard, s, movebackward ); moveMap.bind( keyboard, space, jump ); moveMap.bind( mouse, xaxis, yaw ); moveMap.bind( mouse, yaxis, pitch );
change all that to
[code]/*
moveMap.bind( keyboard, a, moveleft );
moveMap.bind( keyboard, d, moveright );
moveMap.bind( keyboard, w, moveforward );
moveMap.bind( keyboard, s, movebackward );
moveMap.bind( keyboard, space, jump );
moveMap.bind( mouse, xaxis, yaw );
moveMap.bind( mouse, yaxis, pitch );
*/[code]
If you can still move in your game after doing that then there is something equivalent to config.cs somewhere, if not then you should be getting errors in your console every time you press 't'.
#70
12/09/2007 (5:04 pm)
Oh I didn't see your latest posts while I was typing let me see what I can do in tutorial.base
#71
EDIT: Well I'm flying in starter.fps but I am thinking I forgot to put in that shaking fix issue.
12/09/2007 (5:07 pm)
Yah... Sorry I forgot to tell you about it.EDIT: Well I'm flying in starter.fps but I am thinking I forgot to put in that shaking fix issue.
#72
in default.bind.cs add
apparently it wanted GlobalActionMap in tutorial.base and not movemap
12/09/2007 (5:10 pm)
Okay got itin default.bind.cs add
GlobalActionMap.bindCmd(keyboard, "t", "commandToServer(\'toggleFly\');", "");
apparently it wanted GlobalActionMap in tutorial.base and not movemap
#73
12/09/2007 (5:18 pm)
Thanks. I can't seem to get Tom's non shaking issue to stop, I added the 2 lines of code he said but now my engine crashes when it loads the level. Am I missing something?
#74
12/09/2007 (5:20 pm)
Did you also addQuote:I figured out what I did wrong: I used Tom Spilman's fix to smooth flight, but I missed his note about adding lines in Player::readPacketData(). For fellow code box scanners out there, you need to add the following lines to player.cc (add the lines denoted with plus signs):
void Player::readPacketData(GameConnection *connection, BitStream *stream)
{
...
stream->read(&mHead.x);
stream->read(&mHead.z);
stream->read(&rot.z);
+ stream->read(&rot.x);
+ stream->read(&rot.y);
rot.x = rot.y = 0;
setPosition(pos,rot);
#75
12/09/2007 (5:22 pm)
Also? Isn't that the only thing to do?
#76
12/09/2007 (5:25 pm)
Oops I quoted the wrong deal I updated it.
#77
12/09/2007 (5:26 pm)
Oops, lemme get that.
#78
12/09/2007 (5:36 pm)
Nope, still shaking. And the thing for tutorial.base isn't working.
#79
12/09/2007 (5:40 pm)
I putstream->read(&rot.x); stream->read(&rot.y);in the readPacketData function and the
stream->write(&rot.x); stream->write(&rot.y);in the writePacketData function, but still shaking.
#80
12/09/2007 (5:40 pm)
Your read is fine but your write should look like thisstream->write(mRot.x); stream->write(mRot.y);
Torque Owner Dracola
The method I used was...
In client/config.cs add
in server/scripts/commands.cs add
function serverCmdtoggleFly(%client) { if (isObject(%client.player)) %client.player.toggleFlying(); }Using this code 't' will toggle flight of course you can change that to anything you want.
By default the player starts not flying since I figured most of the time that's how people would want it, but you could change it right as the player spawns if you want.