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 / Model Positioning Help

Author
Message
Enlightened Gamer
14
Years of Service
User Offline
Joined: 4th Oct 2009
Location:
Posted: 8th Oct 2009 19:20
Hey guys,

As part of my college course I have to make a Darkbasic game. I decided to make a first person shooter but I have become stuck at the first step!

I am trying to position the object so that it follows the camera (like you would expect of a first person shooter) but I can not get it to work correctly. I have tried to get assistance from my tutor but he could not figure out what was wrong either in the time that we get for lessons.

Here is a copy of the code I am using:


The main problem I am having is getting the object (gun) to stay with the camera as the camera turns. I have got the object to move back and forth with the camera but when the camera turns the object just rotates in the same spot.

I would be very greatful for any help that you can provide me!
bobbyd
15
Years of Service
User Offline
Joined: 17th Jan 2009
Location:
Posted: 8th Oct 2009 23:37
Hi

I havent tried your code but it sounds like you need the
lock object on command this locks an object to the screen all you have to do is type lock object on then type the number of the object and to unlock the object of the screen lock object off
then the object number.

Hope i helped
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 9th Oct 2009 00:13
That would help with simple objects, but he is using a more complex object. He already asked here about that:

http://forum.thegamecreators.com/?m=forum_view&t=158768&b=10

@ Enlightened Gamer

Does the gun move around? Does it have any animations? If not, just position the object where you want on the camera so it looks good, then press f9. This will take a screen shot of the gun at the bottom of the camera. Next, get that image which is usually stored under "C:\Program Files\Dark Basic Software\Dark Basic\", cut out the unnecessary space so you only have the gun in the image and make sure to colour the background black.

Then, make a plain object, lock it to the screen and texture it with that image. You will have much faster frame rates and the object will not look weird.



TheComet


Make the paths of your enemies easier with WaypointPro!
Enlightened Gamer
14
Years of Service
User Offline
Joined: 4th Oct 2009
Location:
Posted: 9th Oct 2009 00:38
The gun does not have any animation but in my final build I am going to include a weapon model with animatiion so I want to use this early build to iron out any problems before I can focus on the fine details.

I was hoping that there would be one main way of positioning a model to the camera but it seems that there are many different ways depending on the exact requirements.

I guess doing the image method you mentioned will be fine for now and I will have to investigate futher into other methods.

Thanks for your advise... Darkbasic is a lot more complex in places then I was expecting lol.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Oct 2009 06:11
Here's a link to a function for locking an object to the camera without using LOCK OBJECT ON. If you study it, you can actually see and perhaps learn the maths used. But you don't have to know what it's doing to use it.

lock object to camera

Enjoy your day.
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 9th Oct 2009 07:05 Edited at: 9th Oct 2009 08:17
Here's the area i think is wrong with your code. I'll post an edit if I find a way for you to do it.


EDIT:

Threw together a crude way of doing it, but it works. I locked the object to the screen. Positioned the object to the correct place. Added a little gun lag and pointer. And there we go, we have a working fps control setup.

*Note: When you lock an object to the screen you have to make the z position greater then zero because camera position z() then becomes the 0 z position for your object.

Here's the code:
Enlightened Gamer
14
Years of Service
User Offline
Joined: 4th Oct 2009
Location:
Posted: 9th Oct 2009 22:59
Thanks for all the advice guys,

I still cant figure it out while using a model with animation but I think I will forget about the animation until I learn more (I am only 3 weeks into my year long course).

However... thanks to "TheComet" for his advice, using this method should work great until I get to my final assignment when I need animation on the weapons.

Hopefully from now on my posts on the forum wont be bothering people for help lol.

Many thanks

Login to post a reply

Server time is: 2024-05-04 00:02:17
Your offset time is: 2024-05-04 00:02:17