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 Professional Discussion / Help with camera collision

Author
Message
Jamie_Leigh
14
Years of Service
User Offline
Joined: 15th Dec 2011
Location:
Posted: 3rd Feb 2012 00:21
HI I have added this bit of code to my game so that the players score increases when they find a pickup.



The thing is it is only the camera that moves around the level giving a first person feel to it. So my camera does not have a object number and so won't react to "if object collision (9,1)"

is there any way to get this collision to work with the camera?
or maybe even how to assign the camera with an object number?

Thanks
Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 3rd Feb 2012 00:52
Place an object at your camera and hide it? Maybe.
Jamie_Leigh
14
Years of Service
User Offline
Joined: 15th Dec 2011
Location:
Posted: 3rd Feb 2012 01:23
How would I make it so the object stays with the camera as it moved around?
Thanks
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Feb 2012 18:51
Quote: "How would I make it so the object stays with the camera as it moved around?
Thanks "

position object your_object, camera position x(),camera position y(), camera position z()

Bulsatar
15
Years of Service
User Offline
Joined: 19th Apr 2011
Location:
Posted: 3rd Feb 2012 21:22
To add on to Brendy boy and gunslinger...

It would probably be wise to setup a UDT (user defined type) so you can store your coordinates in that and make any changes to those properties and then send those properties to place the object.

For instance:



This way you can use set and use that information for whatever calculations you want and don't have to worry about pulling that information. You can also use that same idea to create an imaginary bounding box around the camera that you can then run fast collision detection on.

Hope that helps
Jamie_Leigh
14
Years of Service
User Offline
Joined: 15th Dec 2011
Location:
Posted: 9th Feb 2012 16:04
Thanks to everyone for all the help,
I'm currently still trying to sort it out I have added this code,


Is there a simpler way of doing this?

Thanks again!
Lewis999
15
Years of Service
User Offline
Joined: 23rd Oct 2010
Location:
Posted: 10th Feb 2012 22:53
Before main loop:

make object cube 1000,1
hide object 1000

in main loop: (not sure how this would interact with your current movement system with the camera)

`fps style movement
rotate camera camera angle x ()+MouseMoveY( )/2.5,camera angle y ()+MouseMoveX( )/2.5,camera angle z ()
rotate object 1,camera angle x (),camera angle y (),camera angle z ()
position mouse 0,0

if keystate (17)=1 then move object 1000,0.2
if keystate (30)=1 then move object left 1000,0.2
if keystate (31)=1 then move object 1000,-0.2
if keystate (32)=1 then move object right 1000,0.2
position camera object position x(1),object position y(1),object position z(1)

if object collision(gem,1000)
inc score,1
delete object gem
endif


Hope this helps.

Login to post a reply

Server time is: 2026-07-10 03:09:46
Your offset time is: 2026-07-10 03:09:46