Jump to content

Home

CG Question - Player Angle?


MasterC

Recommended Posts

Hey there, I've got a question about the cgame side of JKA. I'm currently working on a series of new and different movement modes (more realistic swimming, free falling (Skydiving), flying, etc.), and I'm trying to figure out a way to re-orient the players who are, say for example, swimming. Every played Hydroball before? I wish I could get my hands on the code for that, but what he did is essentially what I want to do (when you were underwater and pressed forward or backward, your body's pitch would change to match your viewing angle).

 

Anyway, if anyone knows where I might look to set something like this up, I'd be very appreciative. I know it probably can be pulled off in the cgame code, but I'm also curious if there is another way to do it just from the server side (if the code has provisions for that in place already). Thanks in advance!

Link to comment
Share on other sites

I have another question related to angles. There are so many mentions of different thisAngles[] and thatAngles[] that I don't know where to start. I want to make a player bend at the waist the way you can do with the mouse when you move the mouse forward or back and change the pitch. But I want to do it without the mouse. Say you press a button called BUTTON_UP and your waist bends back 20 degrees making you look up a bit and you press another BUTTON_DOWN and you lean forward at the waist 20 degress so you look down. How would I do that? I want the model to bend at the waist not just the pitch offset of the camera to change.

Link to comment
Share on other sites

Well, I've made a bit of progress here. I have figured out how to change the angle of the player to match the viewing angle (for swimming and skydiving and such). The way I've done it is by modifying the code in the BG_G2PlayerAngles method inside the "bg_pmove.c" file. all I had to do was change:

 

legsAngles[PITCH] = 0;

 

to:

 

legsAngles[PITCH] = torsoAngles[PITCH];

 

I also used a simple if statement to check a "userint" value before atempting this, so that otherwise it would just set legsAngles[PITCH] to 0 like normal.

 

Unfortunatly, I did encounter a problem. Because of the nature of this function, I can't check what buttons the player is pressing inside of it. This in turn means that I can't cause the player to lean from left or right or change in pitch from forward to backwards easily. The only things that the function provides are the player's viewing angle and current velocity. Just thinking about how I'm going to derive a relative pitch and roll from those two things is giving me a headache. . . am I missing something fundamentally simple? Vector math is not really my favorite part of JKA programming. . . Oh well. I'll just give it another look trigonometrically later. . . Argh. . . :)

 

Oh, and as for your question, Vruki, the way I'm looking at it now, it won't be incredibly easy to modify your torso's angle based on a held button from within this function. You can either add in a "userint" value to hold bits for held buttons, or you can find another way to change the angle outside the function. Let me know if you do, too. . . I'll be looking for alternatives myself (I'm already using "user" values a lot as it is! :doh: ).

Link to comment
Share on other sites

Thanks for the information. I'll see if I can make it work for me. The buttons are actually no big deal. Really I'll just check the value of "aimHigh" and "aimLow" qbools. The important thing for me is to check if either torsoAngles[PITCH] or legAngles[PITCH] is the angle I need to switch.

 

By the way, pm->cmd.buttons seems to be available in BG_G2PlayerAngles. Can't you use it?

 

*update*

 

I can't get this to work using torsoAngles[PITCH]. I guess I'll try legAngles[PITCH] but since torsoAngles had no effect at all I am pessimistic.

 

:Pout1:

 

*update 2*

 

legsAngle was the one! Yay! Thanks again C.

 

:thumbsup:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...