Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Car drifting (https://forums.graalonline.com/forums/showthread.php?t=68892)

wild8900 09-23-2006 07:59 AM

Car drifting
 
How does the drifting for the cars on UN work? In other words, how would I make drifting for a car script that I have. It moves in the 360 degree direction that changes to the arrow key direction. How does drifting work in general?

EDIT: btw, I am willing to post parts of my script if it helps...

Twinny 09-23-2006 03:38 PM

Would be much the same as an ice skating rink script. I can provide a GS1 example though I'm not sure how useful that would be. PM me if you would like it.

wild8900 09-23-2006 06:24 PM

Thanks, im better with gs1

Crono 09-23-2006 07:01 PM

they got drifting on un? if so i should play there all day :P

zim5354 09-23-2006 07:50 PM

Quote:

Originally Posted by Gerami (Post 1221148)
they got drifting on un? if so i should play there all day :P

UN cars suck. :(

Yen 09-23-2006 08:03 PM

What do you mean by drifting?

k0rupt_ed 09-23-2006 08:20 PM

they have drifting? wtf?

wild8900 09-23-2006 09:24 PM

not really drifting but what I mean is, when you are giong in one direction but turn to A different one really quick, you still move in the other direction a little bit with inertia.

zim5354 09-23-2006 09:33 PM

Quote:

Originally Posted by wild8900 (Post 1221219)
not really drifting but what I mean is, when you are giong in one direction but turn to A different one really quick, you still move in the other direction a little bit with inertia.

There scripting is just bad im pretty sure that wasnt intended lol.

Chompy 09-23-2006 10:18 PM

360 degree
 
Quote:

Originally Posted by wild8900 (Post 1221000)
360 degree

For that, cos and sin would be good

wild8900 09-23-2006 10:22 PM

right, I already know that, my car script can move in 360 degrees with some pretty good collision detection. I just chose to limit it to 8 or 4 directions like UN.

Chompy 09-23-2006 10:25 PM

you made it like, when pressing left or right, angle++/-- and then up is acceleration and down is brake?

Yen 09-24-2006 12:40 AM

Well, you'll want to have two variables: xvelocity and yvelocity

While the car is moving, you'll increase the x/y by xvelocity and yvelocity.
When you press the up key, you'll decrease y velocity by the acceleration until it reaches the speed limit. When it reaches the speed limit, it stops increasing the velocity.
Do the same for the other keys.

PHP Code:

function onCreated() {
  
this.xvelocity this.yvelocity 0;
  
this.acceleration .1;
  
this.speedlimit 1;
}

function 
onTimeout() {
  for (
04k++) {
    if (
keydown(k)) {
      
this.xvelocity limit(this.xvelocity vecx(k) * this.acceleration,-this.speedlimit,this.speedlimit);
      
this.yvelocity limit(this.yvelocity vecy(k) * this.acceleration,-this.speedlimit,this.speedlimit);
    }
  }
}

function 
limit(val,min,max) {
  if (
val minval min;
  if (
val maxval max;
  return 
val;



Chompy 09-24-2006 01:17 AM

that Script looks good :) well you only miss one thing :O

setTimer(0.05); in timeout and/or in onCreated()?

or not needed? :confused:

Yen 09-24-2006 06:19 PM

I didn't give the full script, I just gave a general idea of how to do it.

Chompy 09-24-2006 09:44 PM

ah, I was wondreing, because I know you can script :P

^^

ApothiX 09-25-2006 04:06 PM

Quote:

Originally Posted by zim5354 (Post 1221172)
UN cars suck. :(

**** >:[

Quote:

Originally Posted by zim5354 (Post 1221229)
There scripting is just bad im pretty sure that wasnt intended lol.

Actually, it was. Incase you haven't noticed, if you make a sharp turn with a car in real life, the momentum from the original direction you were travelling doesn't just magically dissapear.

Twinny 09-25-2006 04:12 PM

It wouldn't surprise me if the "drift" was caused by bad scripting =p

ApothiX 09-25-2006 05:47 PM

Quote:

Originally Posted by Twinny (Post 1222071)
It wouldn't surprise me if the "drift" was caused by bad scripting =p

Reed b4 u post plx.


All times are GMT +2. The time now is 12:59 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.