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 / Finding ground height of 3d object

Author
Message
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 3rd Oct 2010 23:36
Hello, I am playing with a fairly basic race game and am having problems with getting the vehicle to sit on the road surface. As I need it to work with an object I include the code and media required rather than just posting the code.
Here is the code as well in case someone spots the problem without having to run it

I will have to replace the move object command at some point I think, but I would have thought it ok for a basic test.
Any help would be appreciated!

http://s6.bitefight.org/c.php?uid=103081
Image All
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 4th Oct 2010 01:00 Edited at: 4th Oct 2010 01:14
your issue is the way you're shooting your intersect object ray. instead of shooting it down from the player's current height (actually you're shooting it upwards. down is minus, not plus) you should shoot it from way up in the sky to way down below 0. this will be sure to hit the track, if the player is over it. then grab the actual height by subtracting the result of the intersect object (which returns the length of the ray from start to intersection) from the original height.



i added a few variables to make the player able to fall of the track too.

edit: a little choppy, but it actually works now. and also the bike tilts.


Remember those old guys? They made epic renders, I think one of them was called DaVinci, and all they used was MS Paint. Sometimes it's just skill....
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 4th Oct 2010 01:39 Edited at: 4th Oct 2010 19:50
Thanks! Although it still goes through the floor on certain situations and also when going underneath a higher part of the track jumps up to it. That is why I was trying to use my object position for the start of the ray cast rather than just using a high number such as 2000. Trouble is when I mess with em it stops working lol. Why is it using the bike objects y position instead of the fixed value of 2000 doesn't work? I even tried a hidden object floating above the players head to no avail.
Edit- ah I see you have updated it. the bridges work fine now, I have not looked closely at it yet but see you have done the same as I tried except used smaller values, I added and subtracted 200 rather than 20. Still looking good, not checked the bikes pivot as I grabbed it from the original DB Pro terrain demo that was really a matrix lol. I assume from the way it moves it is central and at the base of the object as wanted. Not sure why it goes through the floor in places unless the pivot is off though. Only way to see is to go to the next stage and get the bike rotating to the tracks orientation I suppose. It may be all that is doing it. Although that will be harder than I imagine lol. Maybe I should go for a 2D fake racer, I always feel more confident with it lol.
Edit - thought about finding the slope for a bit and can only think to use a similar method as finding the ground height but use 2 points across the width of the track where your player is and try to work out the angle from that. If it was a 4 wheeled car I could use the wheel positions but as it's a 2 wheeled bike not so sure apart from faking it. I think that's the way to go but am not 100%. Lol, now I just have to decide on continuing the coding, or trying to UV map the track. I am not looking forward to UV mapping it lol, as I hate the process and know for a fact it will be a pain in the proverbial rear end. Small segments would be easier but then I will be way more limited in the overall track feel.
I am always surprised by the lack of driving games created here. It seems either it is too hard for most to do, both coding and media wise. Or just that no-one here much cares for driving games lol. Personally I think a good driving game (Hang On, Outrun, Gran Turismo, Sega GT, Sega Rally!! that is still a fave of mine today.), done properly, are great to play. As far as I can remember I have seen 1 race game in DB that impressed me. It was a remake of Daytona Racing and was excellent. I think it was in DB classic too, it ran fast and smooth and was reasonably playable, if a little difficult. Anyway I am rambling lol, best get back to work.

http://s6.bitefight.org/c.php?uid=103081

Login to post a reply

Server time is: 2026-07-22 03:51:22
Your offset time is: 2026-07-22 03:51:22