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 / Sparky's Collision,help?

Author
Message
Servant Saber
16
Years of Service
User Offline
Joined: 8th Aug 2008
Location:
Posted: 5th Jun 2009 23:19 Edited at: 5th Jun 2009 23:24
Ok, I know this has be discussed to death time and again,

And I really have looked on the forums searching for a

solution, but to no avail.

I'm using sparkys collision Dll with Darkbasic Pro,
And I'm using sample code that shows how to impliment

collision between two objects(Kudos to member RUCCUS for

this code).
My problem is, When I move my sphere object around the level
with the arrow keys, Collision works between the level and
the sphere object.
Now, if I say, attach the camera to the sphere object, or
use "Lock object" and try to collide with the level, it
does not work(It goes right Through the level).
I want the camera to collide with the world object, any ideas what I'm doing wrong here?

I've attached my project with all files included
And here's my code.
You can move the camera with the AWSD keys and the sphere

with the arrow keys.



Attachments

Login to view attachments
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 5th Jun 2009 23:36 Edited at: 5th Jun 2009 23:39
When you use LOCK OBJECT ON, I believe that the collision will stop working. What you will want to do is hide the sphere with HIDE OBJECT or EXCLUDE OBJECT ON, have the user control the sphere, and then each loop position the camera at the sphere's position and rotate the camera to the sphere's angles (if you choose to have the user control the sphere's rotation). In that sense you aren't really controlling the camera directly with the WASD keys, but it looks like you are. That's how I've seen it done anyway.

Alternatively you could omit the sphere object entirely and perform sphere casts using the camera's positions...


In other words, add this to your code right after you call the SlidingCollision function:


<-- Spell based team dueling game!
Monk
16
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 6th Jun 2009 01:07
Move the sphere and perform the collision checking with the sphere and then position it as necessary after the collision, and then after all that, position the camera at the spheres position. This will have essentially the same effect as moving the camera and collision checking the camera. Also, it wont take long to edit your code to implement.

Servant Saber
16
Years of Service
User Offline
Joined: 8th Aug 2008
Location:
Posted: 7th Jun 2009 23:49 Edited at: 8th Jun 2009 13:18
Thanks for your help everyone, but I seem to be having a problem with converting the camera controls to the object.
I can move the object now with the ASWD keys thanks to keeping the camera in the same spot as the user object sphere, but whenever I move my mouse to move the viewport, it seems that the object changes orientation, and NOT the camera, I want the camera to be snapped the the object's facing, so when i move...say the object to the right, The camera goes to the right(Right now the camera is facing one direction and won't follow the object's orientation)
I think there's a simple command to do this, But I guess i'm just being dumb, any ideas?


Monk
16
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 8th Jun 2009 19:17
You need to rotate the camera to the objects angle, so maybe change this code:


To:


That should work

Login to post a reply

Server time is: 2024-11-24 06:48:56
Your offset time is: 2024-11-24 06:48:56