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 / Collisions

Author
Message
Parton
17
Years of Service
User Offline
Joined: 25th Mar 2009
Location:
Posted: 25th Mar 2009 12:07
Hi have create a map with a jeep as the player. However i cannot get it to collide with any objects or stop it going off the map.
The collisions i used for my jeep to objects:

To stop the object going past the matrix:


Please can some one help me a.s.a.p. Thanks Dan.

Parton
Quirkyjim
17
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 25th Mar 2009 21:50
What are X# and Z#?

~QJ
That's what they WANT you to think...
Link102
21
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 26th Mar 2009 00:50
they are obviously the X an Z position of the object

if newxvalue > 0 and newxvalue < SIZ_TERRAIN and newzvalue > 0 and newzvalue < SIZ_TERRAIN
x# = newxvalue
z# = newzvalue
endif
what is newxvalue? I dont see any value added to this variable

Quirkyjim
17
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 26th Mar 2009 21:52
NEWXVALUE(Current X Value, Angle Value, Step Value) is a command that will get a new x position for an object.

Quoted form DB Help:
Quote: "
This command will return a value that represents the new X position of a point in 3D space. This command is used in conjunction with NEWYVALUE and NEWZVALUE commands to move from one point in space to another point in space based on a specified angle. Rather than using COS/SIN maths, these commands simplify the task of moving coordinates within 3D space. The step value specifies how far in the specified direction you would like to calculate. The parameters should be specified using real numbers."


~QJ
That's what they WANT you to think...
Link102
21
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 27th Mar 2009 00:46 Edited at: 27th Mar 2009 00:49
I know that, very handy for camera work.
However "x# = newxvalue" won't do anything


Quirkyjim
17
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 27th Mar 2009 23:48
Ah, I see what you're saying. I thought that you were talking about his use of the function, not the unused var.

~QJ
That's what they WANT you to think...
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 28th Mar 2009 02:37
good effort here
At the moment your collision detection routine is just placing your car where it is, what you need is to know what direction the car is going and push it back in the opposite direction a little or stop it from going in that direction.

To do this we need to store which buttons are being pressed (as its the user that decides where the car goes)...

this also makes it much easier to type
We first move the object as usual (but using the variables to get the new positions) and then we test for collisions, if we get a collision we invert the inputs to make the vehicle go the opposite direction (multiply them by -1), you'll need to have the movement code as a subroutine to do this so we can call it twice.

another way you could do it is to have two hidden objects at the front and back of the car and if they collide send them in the opp direction (like having bumpers).

The Universe has been erased by a mod because it was larger
than 240x80 pixels.

Login to post a reply

Server time is: 2026-07-22 00:40:15
Your offset time is: 2026-07-22 00:40:15