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 / 2 problems

Author
Message
DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 6th Mar 2006 01:54
ok i put my fps on hold so right now i am making a 3D platform game and there are 2 things i need help with. one is jumping to is collision. i looked in the DB help file for collision but there is to much other stuff with it that i dont know hwat to put in my game.
when i say i need help with collision i dont need it for the matrix just the platforms.you know what dont pay any attention to what i said about jumping i just need help with the collision. here is my code. i hope i didnt confuse you.


Check out my site!(unfinished)
http://www.freewebs.com/dbnewbie/
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 6th Mar 2006 03:38
this should work. This is a concept that i have used before. It encompanses gravity,jumping, and collision. What I like about this method is that the longer you are in the air, the faster you fall, giving a more real feeling to it.


there may be some problems with the code i just gave you so test it out, just to make sure. Another advantage to this method is that you could set the object number that you are affecting to a variable, then in you main loop use a for next loop to use the 2 subroutines(gravity and collision) on all of your objects that need it. THis will obviously require a little extra tweaking of the code

Hope this helps
DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 6th Mar 2006 03:42
ok thank you i will try i out in a bit.

Check out my site!(unfinished)
http://www.freewebs.com/dbnewbie/
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 6th Mar 2006 15:41 Edited at: 6th Mar 2006 15:55
That system would only work if you're using primitive objects like boxes or spheres. If you're creating a map in a modeling program than you wont be able to move around anywhere unless you switch to polygonal detection which is slow and still unreliable.

If you're just interested in colliding with the surface of the platforms (so they stop when they land on the platform) then INTERSECT OBJECT is your friend.

Here's a very basic system:



Basically the INTERSECT OBJECT command checks for any objects passing through two points, you specify what object to be checked against in the first parameter for INTERSECT OBJECT. The next 3 parameters specify the starting position of the intersection "ray", and the last 3 specify the ending position.

The function checks for intersection between the bottom of the object we want to stop colliding with the ground, to the center of the object. This way, if there's any intersection at all we know that the object must be standing on the ground.

Once we know the object is intersecting with the second object, we reposition it at its X, its Y + Speed and its Z. This way the object will move up when they hit the ground.

As I said this is a very basic system, it can cuase vibration but it works. Using this method you could take the system further, instead of moving the object upwards you could switch the falling code from moving the object downwards to forwards, eliminating the vibrations.

Incase you're confused about the function parameters here they are:

Object1 - The object you want to check collision with, so in your case the character you control.

Object2 - The object you want to check collision against, in your case the map object.

Speed# - The speed the object moves upwards when it hits the ground. Change it to suit your needs.

Below I'll show a basic example of using the function. If you have multiple map files you can use a loop to check with intersection with all of them, for example:



Like I said before this only covers collision with bellow the object, but you could easily add another intersection check above the object aswell. The side collisions are more complicated and can involve complex maths if you want to get very precise sliding collision, however if you're just looking for simple polygonal collision using htis method you could attatch 4 limbs onto the object, 1 on each side. Then shoot an intersection ray from each limb to the object, if an intersection occurs you can move the object in the opposite direction (so if theres an intersection to the right then move the object left).

<EDIT> Ok I checked out the jumping code provided and it'll work but it'll be fairly jumpy. Since you're setting the velocity to a high number theres no smooth transition going up, only going down.

He does have the idea though. Basically you move the object up at a descending rate of speed, and then down at an ascending rate of speed.

Not much time to explain now but here's a simple program break it down and figure out what it does:



For more info on this type of jumping and collision check out my tut at http://www.ruccus.net/Tutorial.htm.

Goodluck,
- RUC'

DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 6th Mar 2006 17:06
yah ruccus i used your jumping part in my FPS it made the object jump but when i pt the code in my platform it didnt work i want it to make the sphere jump i will show you my jumping code.


Check out my site!(unfinished)
http://www.freewebs.com/dbnewbie/
DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 6th Mar 2006 17:09
nevermind what i just posted i used the code from the program that you gave me at the bottom of the post but it doesnt have the matrix collision that my origanal code had and the turing is diffrent can you somehow fix that.

Check out my site!(unfinished)
http://www.freewebs.com/dbnewbie/
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 6th Mar 2006 17:54
That program was just to show you how you'd go about jumping, if you understand it it shouldn't be too hard at all to implement into your current code with the matrix collision. The same goes for the collision function I gave aswell.

DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 6th Mar 2006 18:45
oh ok thank you i will look more closely.

Check out my site!(unfinished)
http://www.freewebs.com/dbnewbie/

Login to post a reply

Server time is: 2024-11-27 03:51:27
Your offset time is: 2024-11-27 03:51:27