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 / gun swaying

Author
Message
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 17th Apr 2004 02:04
when u walk in my fps i want it to look good so can somone tell me how to make my guns sway and stuff when i walk dont bother saying just use sin cos and tangine because i have not a clue thank u

i used to be indecisive but now ime not so sure
Hamish McHaggis
22
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 17th Apr 2004 02:54
I'm afraid it's very hard to do good gun swaying without triganometry. Learn trig, it's very easy and you wont get far in 3D without it.

Trying is the first step towards faliure.
Athelon XP 1600+/Radeon 9600 Pro/256 RAM
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 17th Apr 2004 17:50
ummm whats triganomtry

i used to be indecisive but now ime not so sure
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 17th Apr 2004 21:31
It's a strand of maths. It focuses on shapes, mainly triangles.

Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 17th Apr 2004 21:34 Edited at: 17th Apr 2004 23:15
sines cosines and tangents

they are not that hard, this is a sine plotted over time


sync on:sync rate 20
do
for i=1 to 720
dot i,(sin(i)*200)+200
sync
next i
cls
sync
loop


that wavy line is what you need to make your gun swing from side to side, if you look at the code then you can see that all it does is plot the sine of all the degrees from one to 720 (two complete rotations), if you watch as it draws it you can see that it "moves" slower at the top and the bottom, thats what you want to make the gun move from side to side in a convincing manner, as it gets to the end of the swing then it slows down, then it swings fastest when it passes through the middle, this next snippet swings a cylinder from side to side using sine, notice that the movement looks natural
sync on:sync rate 40
make object cylinder 1,3
scale object 1,10,100,10

do
for i=1 to 360 step 10
zrotate object 1,(sin(i)*10)
sync
next i
loop

it`s rotating in the wrong plain for a gun and if you turned the object to lie flat and placed the camera behind it then you would notice that the gun swung from side to side, but not a hair up or down, this looks unatural since a gun wouldn`t swing like that when you carried it, so you add another smaller sine movement to the equation that will bob it up and down slightly, but you make this one run out of sequence with the other one by using slightly different numbers or it will just move in an ellipse and that would look unatural too

sync on:sync rate 40
make object cylinder 1,3
scale object 1,10,100,10
xrotate object 1,90
fix object pivot 1
position camera 0,2,-2
set camera range 0.01,10000
secondarybob=60

do
for i=1 to 360 step 5
secondarybob=secondarybob+8
if secondarybob>360 then secondarybob=0
yrotate object 1,(sin(i)*10)
xrotate object 1,sin(secondarybob)*2
sync
next i

loop


this make the cylinder move somewhat like a gun as you walk, but I exagerated the movement so you can see it in action easily, lower the numbers used as multipliers to make the thing not wave about so much, then all you need to do is to make those numbers relate to the speed, so that if the player is running the gun waves about a lot, and if he is walking or still the gun moves by almost nothing, hope thats some help, cheers

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 21st Apr 2004 01:43
thanks mentor but i copy pasted the bottom code
sync on:sync rate 40
make object cylinder 1,3
scale object 1,10,100,10
xrotate object 1,90
fix object pivot 1
position camera 0,2,-2
set camera range 0.01,10000
secondarybob=60

do
for i=1 to 360 step 5
secondarybob=secondarybob+8
if secondarybob>360 then secondarybob=0
yrotate object 1,(sin(i)*10)
xrotate object 1,sin(secondarybob)*2
sync
next i

loop

and it doesent work pls help

i used to be indecisive but now ime not so sure
Damokles
21
Years of Service
User Offline
Joined: 28th May 2003
Location: Belgium
Posted: 22nd Apr 2004 16:24
This one should work fine :



- Mind the gap -
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 22nd Apr 2004 23:17
umm works fine here without wrapvalue since the variables don`t go too far out of range and shouldn`t cause problems, just cut`n`pasted it back into the editor and it still works fine here, the only thing I can think of is that somehow some command in Pro (I actualy wrote it in pro) works differently to DB classic, but all those commands are legal in classic AFAIK, weird.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 25th Apr 2004 20:58
thanks works but now ive put if upkey()=1 in front and the dun sways but the camera wont move pls help

i used to be indecisive but now ime not so sure
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 26th Apr 2004 00:28
you would need to rewrite the code to make the gun swing and move since this was an example, and didn`t allow for the gun moveing, you would need to modify it a bit like this...



A bit quick and dirty, but you should be able to see the idea, I reduced the swing a bit as well, you could just move the gun from side to side and up and down, but I feel it looks better swinging around a point, since it would tend to pivot around the hand holding the gun IMO (not that I am an ex mercenary or something, this is just what I think would happen )

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 26th Apr 2004 20:55
thenks but i cant get it to work this is what i put (yea right ex mercenery we all know u was moohahahaha mooohahahahah) pls help

i used to be indecisive but now ime not so sure
MrNick
21
Years of Service
User Offline
Joined: 23rd Feb 2004
Location:
Posted: 26th Apr 2004 20:57
you don't have to know trig, lol just go to CodeBase and there's a great entry for gun swaying. with a couple of editions, it should work for you.

Make games!
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 27th Apr 2004 20:44
thank u

i used to be indecisive but now ime not so sure
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 27th Apr 2004 20:58
but umm where is it and is it for dbc pls

i used to be indecisive but now ime not so sure
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 1st May 2004 00:49
well can u tell me i sarched for it but couldent find it

i used to be indecisive but now ime not so sure

Login to post a reply

Server time is: 2025-05-23 11:27:40
Your offset time is: 2025-05-23 11:27:40