Discuss Scratch

iolani
Scratcher
28 posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

Project here: https://scratch.mit.edu/projects/104104784/
New Version of Project: https://scratch.mit.edu/projects/104108206/

I'm using the main controller the invisible car.
The visible car is just supposed to lag and spin out a bit as you turn while slowly returning to the current direction.

Any ideas?

Last edited by iolani (April 5, 2016 19:06:13)

crisostimo
Scratcher
500+ posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

Cool little game. I think you could really make something fun out of this.

I find it basically impossible to debug a program with so many forever scripts. There is no way to know which scripts are running in which order or how frequently one instruction gets called in comparison to another. My advice to you is the same as I give to most people who post here: try to re-implement this without using the forever blocks.

For instance you could have a single script that you trigger once you increase the velocity. It could repeat until the velocity gets back to zero. Inside that look you should keep anything that influences turning the car. If it's all in one loop you can discover much easier how it behaves differently than you expect.
iolani
Scratcher
28 posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

Do you have an example of how I would structure the velocity change using only broadcasts?

I just fixed it to use broadcast, but the “art sprite” still spins in the wrong direction. I think the issue is with how I have the “art sprite” interpret the velocity variable.

http://i.imgur.com/Y3jpF2p.png

http://i.imgur.com/fUM4yb4.png

Last edited by iolani (April 5, 2016 01:07:23)

iamunknown2
Scratcher
1000+ posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

iolani wrote:

Project here: https://scratch.mit.edu/projects/104104784/

I'm using the main controller the invisible car.
The visible car is just supposed to lag and spin out a bit as you turn while slowly returning to the current direction.

Any ideas?
It does work. However, if you're talking about spinning out way too much, you can limit the spin-off to 90 degrees.

I think some of the problems you mention (but I can't find) are due to the fact that pointing downwards is considered 180 degrees, while one tiny 1 degree clockwise would make it -179.

Last edited by iamunknown2 (April 5, 2016 03:19:53)

iolani
Scratcher
28 posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

iamunknown2 wrote:

I think some of the problems you mention (but I can't find) are due to the fact that pointing downwards is considered 180 degrees, while one tiny 1 degree clockwise would make it -179.

Yeah, the problem is that direction changes from 1 to -179 so sometimes when you turn while facing downward will cause the car to spin all the way around the other way instead of correct towards the direction of the car.

iolani
Scratcher
28 posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

Bump.
BKFighter
Scratcher
1000+ posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

iolani wrote:

Bump.
The problem is the car is allowed to turn that far off. Once the car get past about 90 degrees left of right of the direction of travel, you should just have a spin out.
iolani
Scratcher
28 posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

BKFighter wrote:

iolani wrote:

Bump.
The problem is the car is allowed to turn that far off. Once the car get past about 90 degrees left of right of the direction of travel, you should just have a spin out.

Hmm, so how do I determine if the distance is more than 90 degrees away from the direction of the controller?

If ( Direction of Artsprit + 90 ) > direction of controller

Wouldn't that still run into the same problem as before. When when you face up or down on the map, it hops from -180 to 0?

http://i.imgur.com/MPWoTMw.png

Last edited by iolani (April 6, 2016 19:33:43)

BKFighter
Scratcher
1000+ posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

if <([sin v] of ((direction::variables) - (wanted direction))) > [0]> then
Left :: grey
else
right::grey
end
Is that what you wanted? The value of
 ([sin v] of ((direction::variables) - (wanted direction)))
can be used to determine how far to turn.

Or you can use scripts I developed yesterday after looking at this: https://scratch.mit.edu/projects/104221093/
iolani
Scratcher
28 posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

Awesome info! thanks. It's gonna take a bit to wrap my head around some of math added to the direction. (I'm still using 1.4 so I'll have to comment where each section starts/stops)

But I think I can figure it out from here.

Last edited by iolani (April 6, 2016 20:14:17)

awesomedude123455
Scratcher
1 post

Drifting Car Script Test? Why won't the drift turn in the right direction?


if <( of ((direction::variables) - (wanted direction))) > > then
Left :: grey
else
right::grey
end


how do you define left/right


BKFighter
Scratcher
1000+ posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

awesomedude123455 wrote:

if <( of ((direction::variables) - (wanted direction))) > > then
Left :: grey
else
right::grey
end


how do you define left/right


Necro.

Last edited by BKFighter (May 27, 2016 16:14:33)

Harakou
Scratcher
1000+ posts

Drifting Car Script Test? Why won't the drift turn in the right direction?

awesomedude123455 wrote:

if <( of ((direction::variables) - (wanted direction))) > > then
Left :: grey
else
right::grey
end


how do you define left/right


That really depends in your project - it would be better to create a new thread with your question and some details about your project instead of bumping an old one. Thanks!

Powered by DjangoBB