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.

Newcomers DBPro Corner / FPS problem with "first person"

Author
Message
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 27th Aug 2005 10:05
I\'m trying to make my own FPS game but have a problem with keeping your weapon in front of you...

here\'s the code I\'m using and you\'ll probably see how to fix this straight away:



I\'m trying not to use lock object on,coz that gives positions 0, -1 and 1.5, which is normally NOT it\'s current position in 3D space... can any one help?

...maybe one day I'll finish a project
olivehehe 03
19
Years of Service
User Offline
Joined: 26th Aug 2005
Location:
Posted: 27th Aug 2005 10:28
hmmm.... is that code part of the game loop or something else? If it's part of the main loop then the move object line could cause problems because that will move CurrentWeapon forward 0.5 units every loop. Instead use trial and error to find the right position and put it all on one line like this -



Also instead of getting the object to follow the camera, try making the camera follow the object. You would need to mess with your code a bit (eg. changing the position of the camera instead of CurrentWeapon in your example), but it would probably work better, and it would be easier to move around. Hope that helped.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Aug 2005 01:01
before the loop:



in the loop:




TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Aug 2005 01:17
No-one heard of Lock Object On?

TDK_Man

Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 28th Aug 2005 01:41
The tutorial certainly mentioned it
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 28th Aug 2005 06:12
TDK - mentioned at top, don't want lock object on, if it's locked on, the camera's position may be 500,10,600 for example but the object is always 0.5,-1,1.25

since bullets are created at the objects position, they'd be placed at the bottom left corner of the world if it was locked on...

I'll try Toaster's suggestion first... I always assumed that telling it to yrotate first, then X, then Z would effectively be "set object rotation yxz...

Then I'll try olive's idea, and if it helps, this is part of the loop...

If that doesn't work... I'll be back here whinging again.

...maybe one day I'll finish a project
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Aug 2005 06:23
SimSmall:

My apologies - didn't see that. Was lazy I'm embarrased to say and didn't get past the code snippet!

Slaps own wrist...

Anyway, it does work with Lock Object On. I did some playing around with it a long, long time ago. Let me see if I can dig out the code for you by way of an apology...

TDK_Man

SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 28th Aug 2005 06:41
Thanks Toaster! The rotaton now works like it's supposed to.

Now I just need to figure out keep the gun constantly "in your right hand" without locking it (Any help is more than welcome!)...

locking it, creating bullets at the camera's rotation and position +0.5 will work - but you can only do this for human controlled characters with a camera following them. CPU controlled players don't have camera following them (if I ever built some of these) and in multi-player you would see your own weapon fine, but I think everyone else would send their weapon positions as 0.5,-1,1.5 (which is where they're locked to relative to the camera) -- and so everyone else would appear weaponless (such is my thought anyway)...

...maybe one day I'll finish a project
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Aug 2005 07:22
In multiplayer mode, you would use models with guns to represent them (from your viewpoint).

They would see you as a model with a gun in the same way.

All players would see through their own camera and their own guns would appear as they should.

As I said, I did this a while ago with a firing rifle - complete with nozzle-flash, but I can't for the life of me find it anywhere!

TDK_Man

Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 28th Aug 2005 07:29
*apologies also*
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 28th Aug 2005 17:12
Quote: "I can't for the life of me find it anywhere!"


nooo! -- that's depressing...

...maybe one day I'll finish a project
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Aug 2005 17:53
@TDK

locking objects on can make parts seem 'inside out', it really gets quite annoying..

@SimSmall

to keep the gun in your right hand looks hard but its quite simple, here's how

First keep this before the main loop


then, in the main loop:



i haven't tested it, but it should work


SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 28th Aug 2005 18:01 Edited at: 28th Aug 2005 18:29
I take it that I replace any "object 1" with "object CurrentWeapon"?

...maybe one day I'll finish a project
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Aug 2005 18:05
well, what object number is your gun? just replace any '1' with the object number, unless you do "currentweapon=object number", and you replace any "object 1" with "current weapon"


SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 28th Aug 2005 18:30 Edited at: 28th Aug 2005 19:10
Tried now -- It's almost right. looking at 0 and 180 it's a centred weapon, not right handed. looking at 90 and 270 it's a long way out in front... but apart from that, it's very close to being right. Probably just needs a little fiddling with the numbers...

Thanks for this.

Edit:

That now works -- was just a thing with playing around with the numbers...

gxa#=wrapvalue(curveangle(camera angle x(),gxa#,20.0)) 20 changed to 1 (didn't like the dragging effect)
gya#=wrapvalue(curveangle(camera angle y(),gya#,20.0)) 20 changed to 1
gx#=newxvalue(camera position x(),gya#,50.0) 50 changed to 1.5
gz#=newzvalue(camera position z(),gya#,50.0) 50 changed to 1.5
gy#=camera position y()-10 -10 changed to -1
position object 1,gx#,gy#,gz#
Added line: yrotate object CurrentWeapon,wrapvalue(camera angle y()+90)
Added Line: move object 0.5 -- moves it .5 to the right (so looks more right handed)
rotate object 1,gxa#,gya#,0 not changed...

yrotating is now perfect -- and without lock object on Thanks!

...but looking up or down??? this can be xrotating or zrotating depending on your depending on your current yrotation (is this overcome in a similar way? it's probably staring me in the face as well)

...maybe one day I'll finish a project
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Aug 2005 19:19 Edited at: 28th Aug 2005 19:23
hmm, are you sure you still have the "set object rotation zyx" bit..
if so are you sure its zyx instead of xyz, and are you sure it has the right object number?

[edit]
these added lines: heres a better way to fix them
the yrotate one, do it before the main loop


and for the other one, change these lines:

gx#=newxvalue(camera position x(),gya#,1.5)
gz#=newzvalue(camera position z(),gya#,1.5)

to

gx#=newxvalue(camera position x(),wrapvalue(gya#+45),1.5)
gz#=newzvalue(camera position z(),wrapvalue(gya#+45),1.5)




SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 28th Aug 2005 19:29
object pivot doesn't need fixing, otherwise it would look 90 degrees to the right... all it's there for is:
position weapon at camera
turn object right 90 degrees (from your current y angle)
move it 0.5 (same as camera position x() + 0.5 if I was looking straight on)
now it's a bit off to the right (not perfectly centred), point it straight on

unless your way would do this easier... but that's not how i'm interpreting that...

...maybe one day I'll finish a project
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 30th Aug 2005 14:10
bump bump
nudge nudge
hope some one can help...

...maybe one day I'll finish a project
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 31st Aug 2005 03:30
I found the code I was talking about, but unfortunately it was on a corrupted CD so I can see the files but they are all empty.

I actually did the program as part of programming lessons I was giving a while back, so I gave the guy a ring and he said he might still have the CD he took away with him.

If he finds it, he says he will email it to me. If and when he does, if you haven't sorted it, I'll post it.

TDK_Man

SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 31st Aug 2005 08:14
until then, I'll remain -- very bored...

...maybe one day I'll finish a project
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 31st Aug 2005 15:34
OK, I've still not heard from my mate Tony, so I decided to modify an existing program.

Did you want the gun position to look like this?



TDK_Man

CaMeRoN H
19
Years of Service
User Offline
Joined: 21st Aug 2005
Location: Who knows?
Posted: 31st Aug 2005 17:10
i have mine


that position it good depending on ur gun


Current Project: Stealth Operations: Release Date: September
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 31st Aug 2005 21:43
Something like that sort of position all it needs is a little fliddling with numbers if it's not quite right...

Cameron: read first post about lock object on...

...maybe one day I'll finish a project
thinkdigital
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location:
Posted: 31st Aug 2005 22:00
In DBC, using lock object on makes it sort of transparent, does it not?
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 1st Sep 2005 10:17
no, to make an object semi transparent, the command is:

Ghost object on <Object number>

...maybe one day I'll finish a project

Login to post a reply

Server time is: 2024-11-27 18:53:27
Your offset time is: 2024-11-27 18:53:27