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 / smooth curves using waypoints? can anyone help?

Author
Message
miki
21
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 26th May 2007 22:53
Hi,

I've been pointing my cars at embedded
waypoint objects and that gets the
cars round the track, but???



code:
point object player,object position x(wp),object position y(wp),object position z(wp)

However, the angles snap.

I want a smooth curve.

I'm sure there's some sin and cos solution but as yet can't figure it out.

Can anyone please help?


regards,
miki.

in the end
Roxas
20
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 26th May 2007 23:51
have u tried curvevalue() command?


[B] - LINKIN PARK - [/B]
NanoGamez guy
19
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 26th May 2007 23:52 Edited at: 26th May 2007 23:54
Try storing the angle of each car and if they aren't pointing towards the next waypoint rotate by 1 degree or somthing. That way you get realistic steering. Also you can change the speed that they turn according to the forward speed. Don't use point object for that because it's very stiff and unnatural.


Nothing is impossible...
No really, it is.
miki
21
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 27th May 2007 01:09
Quote: "Try storing the angle of each car and if they aren't pointing towards the next waypoint rotate by 1 degree or somthing."



if i yrotate the car to arrive at the next waypoint, how do i calculate the required wrapvalue amount?

after doing maths for distances i tried stuff like:

a#=cos(distx#)*sin(distz#)
a1#=wrapvalue(a#)
yrotate object 1,a1#

...and a good few other variations.

i think the solution is maths rather than command based, but i can't figure it out.

thanks,
miki

in the end
Roxas
20
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 27th May 2007 01:15
i already told using curvevalue command..


[B] - LINKIN PARK - [/B]
miki
21
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 27th May 2007 01:23
Quote: "i already told using curvevalue command.."


i'm just looking in db help at curvevalue()
and seeing if it works in my game .....

thanks ...
get back to you.

in the end
miki
21
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 27th May 2007 02:01 Edited at: 27th May 2007 02:09
if i use newxvalue, newzvalue and wrapvalue rather than move and point, i must still use cos and sin maths involving distances to arrive at the required yangle value.....

and i cant see how curvevalue() alone achieves that...

...................................

if you can?
pop this into your editor and run it...




it'll give you a better idea of what i'm after...

thanks,
miki

in the end
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th May 2007 03:40
Try increasing the number of waypoints on your track.

A couple of hundred waypoints isn't unusual on a racetrack and with a lot less distance between each one, there should be less sharp angle adjustments and therefore the steering should be a lot smoother.

TDK_Man

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th May 2007 03:59 Edited at: 27th May 2007 04:04
Hello miki,

EDIT (didn't see TDKs post)
TDK's method is a great way to control the opponent cars position on the track more precisely.

The Full Metal Coder has a great idea also by using curveangle() to interpolate the angle. I added a couple of lines to your example code to show how this is done. Basically, I get the angle to the next waypoint using the point object command, then I turn the object back around to it's original facing and use curveangle to graduate the two angles from object to way point.

You could use the same technique but with a hidden object at the same position as the main object that finds the angles so the only rotation that occurs on the main object is by interpolation.

Here's the adjusted code:



Enjoy your day.
miki
21
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 27th May 2007 04:39
ta very much, ya'all,

just about got that one tied down....


"thanks The Full Metal Coder"


regards,
miki.

in the end
Roxas
20
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 28th May 2007 17:36
Also if u are making race game u can use waypoint system like this But if u are making other difficulty modes u should make system that allows u to make the waypoints by driving yourself.. This could easily to do with the arrays


[B] - LINKIN PARK - [/B]

Login to post a reply

Server time is: 2026-07-05 22:39:43
Your offset time is: 2026-07-05 22:39:43