# (Solved) Custom Car Movement

### » Tue Jun 14, 2011 2:50 pm

[quote:19l9tmek]+ On bounce
-> car: Set speed to Abs(expression for get speed) - n * TimeDelta[/quote:19l9tmek]

This is something I tried and works perfectly with just the right values. The only problem with this method (and I thought this may happen when thinking about it) is collisions with anything but a "moving" ai car will cause the player car to continually accelerate towards a wall or any other soild and will at times cause the player car to become stuck against a solid object.

Edit: Also, using this method if the car is hits a wall or other solid object when in reverse the car will shoot forward in speed.
B
2
G
1
Posts: 37
Reputation: 524

### » Tue Jun 14, 2011 4:31 pm

Yes, that's why I said, that it only makes sense against other cars
It is just a start, you would have to further split the events by adding sub-events, to catch all possible situations, e.g.

+ car's speed is negative
-> set a variable to -1
+ else
-> set a variable to 1

+ on bounce
++ colliding with another car
--> Set speed as mentioned
++ else
+++ variable is -1
---> do what is needed if the car hits anything but a car, while driving backward
+++ else
---> do what is needed if the car hits anything but a car, while driving forward

It should be doable. But, of course, you can always try to do it with custom behavior. It's just, that you don't need to completely redo the car behavior, just those on bounce situations, and therefore events are the easier solution with less overhead.
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

### » Tue Jun 14, 2011 5:09 pm

[quote="tulamide":migb5uuf]Yes, that's why I said, that it only makes sense against other cars
It is just a start, you would have to further split the events by adding sub-events, to catch all possible situations, e.g.

+ car's speed is negative
-> set a variable to -1
+ else
-> set a variable to 1

+ on bounce
++ colliding with another car
--> Set speed as mentioned
++ else
+++ variable is -1
---> do what is needed if the car hits anything but a car, while driving backward
+++ else
---> do what is needed if the car hits anything but a car, while driving forward

It should be doable. But, of course, you can always try to do it with custom behavior. It's just, that you don't need to completely redo the car behavior, just those on bounce situations, and therefore events are the easier solution with less overhead.[/quote:migb5uuf]

I think I have decided to go the custom behavior route as I have already gotten the feel that I was looking for with the player vehicle and it would allow me to be able to customize more later if I run into any other snags. Your awesome tulamide, thanks for the help!
B
2
G
1
Posts: 37
Reputation: 524

### » Thu Jun 16, 2011 4:14 pm

I went ahead and took some of your advice. I had a chance to sit down last night and play with events. I did notice for some reason whenever using an "else" event along with the "on bounce" event the action(s) for the "else" event were not firing correctly. Using separate "on bounce" events along with another condition seemed to work fine. I also worked out the reverse issue by using an inverted key press event.

Since I had some extra time last night I put together a small example of what I ended up with so anyone else that seems frustrated with the bounce effect within the "car movement" behavior can have a look at one of the possible solutions. The only thing that is missing from the example is if you let off the gas and then are hit by the ai car, you will come to a complete stop but this could easily be added. Enjoy folks and thanks for the help tulamide!

Bounce Solution
[url:1kbcu9od]http://www.mediafire.com/?4564i6b96dylaga[/url:1kbcu9od]
B
2
G
1
Posts: 37
Reputation: 524

Previous

### Who is online

Users browsing this forum: No registered users and 4 guests