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.

Dark GDK / placing weapons next to the player

Author
Message
xix psycho xix
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 25th Sep 2008 05:45
I was wondering if anyone can tell me how to position a weapon next to the camera to make it appear that the player is holding it. I want the gun to be on the right side, turned slightly inwards towards the camera and sloped up toward the center of the screen. I have no idea how to compute the position to the side of the player though.
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 06:54
Find out what position relative to the player the gun looks natural (through trial and error), then move it to that position every frame.

Example: if it should be PlayerX+10, PlayerY-15, and PlayerZ-8, then do this:



Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
xix psycho xix
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 25th Sep 2008 07:28 Edited at: 25th Sep 2008 07:29
but what if you turn to the left or right? wont the model's position appear to change?

Nevermind, stupid question. But should i use an object instead of the camera? and once the object is where it needs to be, how do i turn it for a natural appearance?
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 17:05
Quote: "But should i use an object instead of the camera? and once the object is where it needs to be, how do i turn it for a natural appearance? "


Oops. Right, replace the player with the camera in my example. I'm not used to 3D.

I'm not on the computer with the GDK at the moment, so I'm not sure about turning yet. I really don't use 3D much.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
xix psycho xix
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 25th Sep 2008 20:47
well that's the problem i see with this. the weapon will appear to turn away from the camera if you simply position it next to and turn the camera.
Gasilli
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Having a party in your garage
Posted: 26th Sep 2008 05:16
Im your camera look code, Im assuming that is what you are doing, you could add code to also turn the gun with the player.
xix psycho xix
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 26th Sep 2008 05:26
Again, i tried using dbSetObjectToCameraOrientation () to turn the gun with the camera, but, say that i position the gun to the right hand side. as you turn, the gun will move from the right to the center to the left to the center and the right again. how do i make the object move with the camera to keep it in the same position? does that involve a lot of complicated math?
Gasilli
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Having a party in your garage
Posted: 26th Sep 2008 05:34
Shouldn't, I did it before in DBPro, but cant remember how I did it. You could try just rotating with mouse look like I said, but im not sure how you do it, my guess is do an object rotation with simmilar code to the mouse look.
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 26th Sep 2008 06:07
I think I found a way to do it without trigonometry (your welcome ).

Every time you turn/rotate/pitch the camera, do this (assuming camera number 1 and gun is object number 2):



See how that works.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Gasilli
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Having a party in your garage
Posted: 26th Sep 2008 07:27
Makes sense, but could you do:



Don't know if that would work, but you could give it a try, with the Y, and Z of course.
xix psycho xix
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 26th Sep 2008 15:02 Edited at: 26th Sep 2008 15:04
Well, the problem is that the gun is still just rotating. it needs to move in 3d space to maintain the appearance of being beside the player, otherwise it will still appear to reposition as you turn.

So basically i need to come up with some kind of equation to figure out where the object should be positioned next when the player turns; unfortunately, i have never been good at making equations
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 26th Sep 2008 19:36
Quote: "Don't know if that would work, but you could give it a try, with the Y, and Z of course. "


dbObjectAngleX doesn't set the angle, it just tells you what it is.

Quote: "Well, the problem is that the gun is still just rotating. it needs to move in 3d space to maintain the appearance of being beside the player, otherwise it will still appear to reposition as you turn. "


Did you try it, or are you assuming it will work that way? I don't see how it wouldn't work if you use both methods that I posted (both, not just the second one).

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
xix psycho xix
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 26th Sep 2008 23:29
well, i tried using both of the methods, like so:



The gun still doesn't turn right, and now it kinda bounces. i think you're on the right track, but i have to try some other things with it...
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 26th Sep 2008 23:30
You're going to have to use sin and cos. I forgot the exact formula, though... sorry.
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 26th Sep 2008 23:42
Try using the techniques described here:

http://forum.thegamecreators.com/?m=forum_view&t=136136&b=22

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 27th Sep 2008 00:00
From the FPS Dark Dungeon example that came with the GDK:



Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
xix psycho xix
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 27th Sep 2008 00:15
oh ok. the variable gunWaggle is what exactly? is the source code for the dark dungeon example included with the program?
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 27th Sep 2008 00:22
Yes. Open the Sample Projects thing.

gunWaggle is just the thing that makes it move back and forth realistically.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 27th Sep 2008 00:23
By the way, if you're firing from the weapon, then it'll be off if you tilt it.
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 27th Sep 2008 00:24
Quote: "oh ok. the variable gunWaggle is what exactly? is the source code for the dark dungeon example included with the program? "


Not sure about gunWaggle. That's probably a bad example. And yes, it's in the sample directory.

Here's an improvement to the original example I gave:



Now it's just a matter of throwing in the trigonometry required.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 27th Sep 2008 00:30
Pshh. Mahoney, get on MSN. I'd like to talk to you.

Login to post a reply

Server time is: 2024-09-30 07:23:21
Your offset time is: 2024-09-30 07:23:21