Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / FPS Gun positioning

Author
Message
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 19th Nov 2005 15:16
Yah... well been having some trivial problems here with a small FPS I'm trying to make in DBC, but you see... this is annoying : using some trick of creating two limbs (one at each side of the player's dummy, for gun positioning) I was able to position the gun where I wished correctly BUT the rotation is -always- wrong. No matter the method I use (or at least the ones I've tried), which are Set Object to Camera Orientation, a mix of xrotate+yrotate+zrotate according to the camera's direction (and player dummy's direction), tried rotating the limbs too... etc. No one of them has worked yet. Thing is, look:



That's correct. I look down...



The heck is this? is there any way to correctly put the gun in the WORLD's position (along with the player's dummy) without faking it by using Lock Object and/or Disable Object ZDepth?

Thanks in advance
-DARKGuy

Captain America
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Here
Posted: 19th Nov 2005 18:34
I would just attach the gun to the bottom of the camera, so that where ever you turn it's always right there. Thats what i do.

-Captain-


Cheers,
Capt. America
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 19th Nov 2005 18:48 Edited at: 19th Nov 2005 18:48
<nevermind>


DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 19th Nov 2005 20:43
Quote: "I would just attach the gun to the bottom of the camera, so that where ever you turn it's always right there. Thats what i do."


But I want to put the gun there so I have the possibility for having two-handed guns

The ARRAYinator
19
Years of Service
User Offline
Joined: 13th Aug 2005
Location:
Posted: 19th Nov 2005 20:56
are they locked on the screen?
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 19th Nov 2005 20:58
Nope, that's what I don't want, but the effect I want to make is the same, WITHOUT locking it.

DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 20th Nov 2005 03:23
Bump?

devastation
19
Years of Service
User Offline
Joined: 11th Aug 2005
Location:
Posted: 20th Nov 2005 16:48
bump acknowledged.

here's the gun positioning code I made for my fps games maybe you can use it



this can be done better with sine and cosine and other stuff, but I'm a wee sophmore so I haven't taken trig yet, so yeah.....

it still works very well and the gun and arms are closer to the camera when you look up then when you look down which makes it more realistic.

the kick# variable is obviously kick and should be initialized in your shooting code and decremented till it's zero. it rotates the gun up during the roatation and it moves the gun back during positining.

I hope this helps and I love your map. Very nice detail on it. Hope to see this project suceed.

verydevastating.com
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 20th Nov 2005 19:08
Hey, nice code Devastation, thanks! thanks for the comments too!

Thing is, sadly didn't worked... well I guess there's no better way than to show code huh? here ya go: (I removed the collision/level/media, so it's just a box in a matrix)

First example try (Glueing the object to a limb):

Failed.

Second example try (Without glueing (sp?) and using a way like Devastation does):

Failed.

Third example try (Using Devastation's like-example with the yrotate thing for positioning the gun at the left/right):

Failed.

Fourth example try (Adding Camera Angle z(), works better, still erroneous):

Failed!

Also I tried to convert the code FPS Gun Movement http://www.thegamecreators.com/?m=codebase_view_code&i=1c1cc9f073a4724e51d7280176bcaf8e from the codebase (works cool in DBP, dunno why it doesn't in DBC), and it doesn't rotates the gun :/

MODIFIED FOR DBC (which doesn't works):


As you can see I've tried mostly everything that has came up to mind... even converting that code :/. All I know is that I seem to have problems with the Z rotation..... but how to correct it? it may be just a speculation though and the problem might be somewhere else... but I hope all that code works for giving some hints at least...

Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 20th Nov 2005 20:06
I had this same problem - I was offsetting a spear for throwing at some dinosaurs (as you do) and didn't want to use bones to attach it to.

What you want, is to be able to 'rotate a point'.



I know it looks scary, but I hope it helps.
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 20th Nov 2005 21:42
move it down, and back depending on the camera's angle

devastation
19
Years of Service
User Offline
Joined: 11th Aug 2005
Location:
Posted: 20th Nov 2005 22:13
woops left some variables in tehre from somewhere else so it was probably positioning the gun between you and 0,0,0. sorry bout taht. here's the fixed code, though tinkergirl's is better if you're able to implement it



good luck

and if you want some gun lag for position, use my old post's code and add



before your camera movement code.

verydevastating.com
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 21st Nov 2005 02:29 Edited at: 21st Nov 2005 02:31
Okaaaay we're progressing... let's see:

Tinkergirl's code was tried to be implemented and didn't worked as expected but also trying Devastation's code helped me see the problem seems to reside between the Camera Angle Z and the orientation I give it. I'm not sure if I should Z rotate the camera too (as I'm using MouseLook, I think isn't neccessary, right?... and if it is, how?) thing is that it's in that value. Also, the rotation works nice when my camera's Y angle is zero, if I change it (turning to the left or right) AND look up or down, it screws up.

This is with TinkerGirl's code: Looks and works good - but the Z rotation screws too:


THOUGH, if you take a look at the code here (which I implemented from Devastation), he uses 0 (zero) in the Z rotation parameter... and works better, but still has that glitch - so it's something good to know and at least to try to difference between both codes. Thing is, I haven't taken trigonometry yet (or any kind of math with angles) so I don't have much idea of the XYZ angles (and thus, COS/SIN math):




EDIT: Corrected typos x)

BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 21st Nov 2005 03:16
DarkGuy,
I have here for you a relic of most ancient glory, dug up from the black ashes of Apollo's past. In side the code box below you will find a power to wield all the forces of Euler and Cartesian with the might of a thousand horses, and the wit of a thousand scholars. Simply copy-paste-run, and you will see the power lies in the order and the system.

Here, in all its ASCII glory, The Rosetta Stone of DBC Rotation:



Pass this around to nubs, keeping intact the credits to almighty muddleglum, for he hath done humanity a most noble service.


I'm going to eat you!
devastation
19
Years of Service
User Offline
Joined: 11th Aug 2005
Location:
Posted: 21st Nov 2005 03:19
Hes a witch! Burn him!

verydevastating.com
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 21st Nov 2005 09:01
That's the most awesome thing I've ever heard Bear, totally XD, you rock xD!... haha, so mystical (Awesome code by the way, thanks a LOT for that! it helped me understand lots of stuff about DB's rotation! ^^) *stores code in safe, safe place*

I seem to have TOTALLY done it! not perfect though, it has some bad glitch when turning real fast (it's logical, due to the rotate-move-rotate back-rotate-move-rotate back way.... but it works! )



I'm trying now to see how do I remove that thing... need to know now how to do that effect without using turn object and pitch object!

YAY!

DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 21st Nov 2005 23:19
Bump

Along with the bump: I'm sure this has been done before but dunno where to find it... a replacement for Pitch Object/Turn Object ? but...y'know how those two work, not like "use yrotate / xrotate" 'cause I've tried that already

SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 22nd Nov 2005 00:18
there is no real alternative besdies (x/y)rotate object - but before your loop starts, try doing
set object rotation zyx <number> outside your loop - without this things get a little weird round the 90 and 270 degree rotation on the y axis...

...maybe one day I'll finish a project
Captain America
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Here
Posted: 22nd Nov 2005 18:23
devastation 328 are you a sophmore in high school?
if you are then cool, cuz i am too!
later!

-Captain-


Cheers,
Capt. America
devastation
19
Years of Service
User Offline
Joined: 11th Aug 2005
Location:
Posted: 22nd Nov 2005 22:10
yup, but I'm a secret programmer. I only admit my darkbasic and cpp knowledge in programming class lest i be thrown into a giant fishtank to be gnawed to death by thousands of hungry sea urchins!

Greetings fellow sophmore! We're teh best because we've already taken algebra (and geometry in most cases) so were not useless, but we still have alot of time before we graduate and have to get real jobs. Just imagine how awesome we'll code when were seniors! And you missed out on a good conversation about high school and stuff in the Slayer Battletanks 2 thread. Such a shame. How's your castle game coming?

and on your gun rotation, instead of using pitch up, why dont u use xrotate object! (question mark ommited because it's rhetorical) it's much better, but you have to use this code or else it messes up because the x rotation is different depending on which direction you're facing (as it doesn't rotate with the camera). try this:



voila! mouse look that doesn't suck atlast! Anything else before I go cry myself to sleep because I didn't get an xbox 360?

good luck
jeff

verydevastating.com
Captain America
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Here
Posted: 23rd Nov 2005 02:50
COOL!

my castle game is coming along great except for my main character (a dwarf) is not working properly. im still trying to get his animation right. He was made in Milkshape 3D, not by me, and when the person made him he/she put all the animation like jumping ducking, slashing, hammering, etc... in the same thing. (if that makes any sense.)

And i dont know how to make it so that when you click the mouse, it only plays a certain portion of the animation (ex: slashing). And im sorta stuck on that, and i havent done anything else yet. So im at a standstill. I would appreciate help in my thread 'Castle FPS game' for anyone that might beable to lend a hand!

-Captain-

PS - jeff do u live in the US, and if so California, and if so what city? if you dont mind me asking! later!


Cheers,
Capt. America
devastation
19
Years of Service
User Offline
Joined: 11th Aug 2005
Location:
Posted: 23rd Nov 2005 02:59 Edited at: 23rd Nov 2005 03:00
you have to get your game to skip to the frame where the slashing is
and otherwise make it play the walking one or whatever



assuming the slash motion is from frame 35 to 60 and the walking is 1 thru 35

and I live in the US but in KC, not cali.

**edit - fixed code error

verydevastating.com
Captain America
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Here
Posted: 23rd Nov 2005 04:00
ok thanks ill try that!

too bad you dont live in CA.


Cheers,
Capt. America
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 24th Nov 2005 04:25
Heh, thanks for that code Devastation !!!

Sorry for the late reply been busy and stuff

Anyways, thing is that Pitch object, and Turn object seem to have a different orientation system, =local=, which doesn't relies in the object angles.... that's why... or at least, how to get the angle of an object when using Pitch Object and Turn Object would be useful too, thinking about it!

Login to post a reply

Server time is: 2025-05-22 19:19:48
Your offset time is: 2025-05-22 19:19:48