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 / Rollercoaster Collision

Author
Message
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 28th Mar 2007 09:21
I wasn\'t sure if i should put this here or in the newcomers corner, but anyway.

I have a code setup for a rollercoaster and i need to set up texture and collision so i don\'t fall of the sides and that comes to my two questions. I was reading through some examples on darbasic and was wondering...

1.Can i use scrolling texture to make it an only has you need to see texture?

2.Should I use sliding collision or box collision for the walls, because i don\'t which is best.

and here is the code i have so far.



Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Mar 2007 12:00
Hello,

Quote: "1.Can i use scrolling texture to make it an only has you need to see texture?"


Not exactly sure what you mean, but if you had a large object, you could scroll the texture as the camera moved so that what was in view was always the same texture portion. If you mean to give the appearance of animation, you could "swap" textures rapidly. I suppose with an evenly sized faced polygon you could scroll the textures in such a way that it would be "see as you need to" - and all the textures would be proportionate. On a matrix, however, I don't think you can scroll textures the same way you can on an object. You can reposition a matrix and then shift it to give the appearance of smooth texture scrolling.

Quote: "2.Should I use sliding collision or box collision for the walls, because i don\'t which is best."


Depending on how you create your walls, there could be many means of collision. One thing to keep in mind, if you have lot's of objects that are going to be checking for collision, it will slow your program down. Since you are using matrices for your track, you could fake the collision with less computational resources.

Collision is basically measuring distances and flagging when these distances have been met or exceded - usually in the form of an area, radius, or a projected ray around or through single points, collections of points, polygons, or collections of polygons. If you can find a way to measure a certain distance between your roller coaster car and the track, you could make your own collision routine. For example, if your track is 100 units wide, and if your car is 50 units wide, it has play of 25 units on each side if it is in the center of the track. The center of a 100 unit track is at 50, so the car could drift to a point at 50+25 on the right and 50-25 on the left. If your car drifts to these points or greater (or less) then you make your program react as if it is colliding with a wall.

Here's an example - now even though there are no walls, the program behaves as if the car is colliding (without actually using collision). The car will keep increasing speed, try to keep it centered with the left and right arrows. SCREEEEECH means it's hitting an imaginary wall:



Enjoy your day.
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 28th Mar 2007 16:54 Edited at: 28th Mar 2007 21:07
Wow, thank you very much for such a detailed description, i appreciate it. Have a nice day.

Latch, in the rollercoaster code you helped me with, i'm using a camera to get around for the first person view. My question is will i be able to apply this collision even though i'm using a camera?

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Mar 2007 03:14
The same principals apply - in fact, you could still use a cube for your collision detection. All you have to do is position it at the camera, and hide it! Here's the same code except I'm putting the camera at the cube's position and hiding it. The camera is shaky because of how I'm calculating the drift. No big deal, that can be changed or eliminated but it makes it look like the track is uneven and dangerous - or maybe it just gives the viewer a headache!



Enjoy your day.
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 29th Mar 2007 03:16
wow dude, is there anything you can't do? You rock!

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Mar 2007 03:23
Thanks for the praise! But I'm still learning just like everybody else - and there's always new things to learn! I just hope my info is helpful.

Enjoy your day.
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 29th Mar 2007 03:24
absolutely, you're giving me a lot of cool code, this is great, i hope i can return the favor one day.

Login to post a reply

Server time is: 2025-05-29 07:11:16
Your offset time is: 2025-05-29 07:11:16