(Solved) Custom Car Movement

For questions about using Classic.

Post » Sun Jun 12, 2011 8:43 pm

Hi, I just started playing around with construct a few days ago and come from a small background in scripting/programming. I have begun work on a top down F1 racer project and now that I have finished the track tiles and ground textures and assembled the first track I am starting to play with vehicle movement. The included "Car Movement" behavior is perfect but with two problems. It seems as though I am unable to edit or disable the bounce effect when colliding with solid objects as this is way to powerful. Also there seems to be no deacceleration function when going in reverse or after a collision.

Are these to functions able to be added/edited by adding a custom movement behavior along with the Car movement behavior or am I going to have to make my own customized movement behavior?

If I am going to have to create a Custom Movement Behavior from scratch can anyone point me in the right direction on how to achieve the feel of the already included Car Movement behavior but with the option to edit or disable the bounce feature as well as a editable deacceleration feature (When going in reverse)?

Much thanks in advance for any and all suggestions/help!
B
2
G
1
Posts: 37
Reputation: 524

Post » Sun Jun 12, 2011 10:32 pm

After some searching I did find this example
http://dl.dropbox.com/u/1646976/GP2.cap

The custom movement in Layout 2 is nowhere near the feel of the included behavior and there is still no deacceleration when going in reverse. It's truly a shame these two options where not made editable in the included Car Movement behavior. :(
B
2
G
1
Posts: 37
Reputation: 524

Post » Mon Jun 13, 2011 12:13 am

The car behavior is rather limited in the points you mentioned. But there's a trigger, 'on bounce', it will be triggered once, exactly after a collision. I used it to get rid of bouncing, by using the action 'stop', in Verve!.

You could use the trigger to dampen the bouncing. Also, decceleration is quite possible.

When the car drives backwards, the velocity is expressed negative. Just create a condition that checks for velocity < 0, and dampen the velocity in some way, e.g. velocity = velocity - velocity * TimeDelta, or whatever is to your likings.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Mon Jun 13, 2011 3:13 pm

[quote="tulamide":3bqslhtb]The car behavior is rather limited in the points you mentioned. But there's a trigger, 'on bounce', it will be triggered once, exactly after a collision. I used it to get rid of bouncing, by using the action 'stop', in Verve!.

You could use the trigger to dampen the bouncing. Also, decceleration is quite possible.

When the car drives backwards, the velocity is expressed negative. Just create a condition that checks for velocity < 0, and dampen the velocity in some way, e.g. velocity = velocity - velocity * TimeDelta, or whatever is to your likings.[/quote:3bqslhtb]

Much appreciated tulamide. I had noticed the "on bounce" trigger and did in fact play with it for awhile hoping to cancel out the bounce by adjusting the speed of the vehicle when compared to it's relevant speed but didn't get a chance yet to really play around with that idea. I am assuming that in order to apply a deceleration system to the car I will have to do this by adding a custom movement behavior to the vehicle on top of the car movement behavior? I was just hoping that by doing so there would be no conflicts by adding more than one behavior.

I would be interested to know how you might go about dampening the bounce effect through the on bounce trigger. An interesting idea, I will have to play around with it.
B
2
G
1
Posts: 37
Reputation: 524

Post » Mon Jun 13, 2011 3:31 pm

I just tested the on bounce trigger by adding stop when the action is triggered but unfortunately coming to a complete stop is not really what i am shooting for. When the car is going around the track and hits the backend of an ai opponent I am trying to more or less cancel the bounce action out from the player controlled car (slightly reducing speed) and then causing the ai opponent to "bounce" slightly from impact. My first step though is trying to get rid of the bounce effect on the player controlled car.
B
2
G
1
Posts: 37
Reputation: 524

Post » Mon Jun 13, 2011 4:13 pm

I would love to give you an exact example, but I don't have a pc to work with Construct for quite a while.

But you really don't need another behavior, just use events that take over control as soon as the car behavior needs tweaks.

Your idea is what I would do, too. Adjusting the speed, via 'Set speed'. Do it over time (n * TimeDelta). And keep in mind, that when bouncing, all values are expressed negative. If you don't want the car to go backwards, but rather slow down against zero, just reverse 'Get Speed' with abs() in the 'on bounce'-event.

+ On bounce
-> car: Set speed to Abs(expression for get speed) - n * TimeDelta

n being pixels per second, e.g. 'Get deceleration'
This would decelerate linear and only when bouncing, making sense only when hitting another car for several ticks. It's just a simple approach to point to the right direction. For more detail I would need to work with Construct. I'm sorry.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Mon Jun 13, 2011 4:23 pm

[quote="tulamide":yfu0o7gh]I would love to give you an exact example, but I don't have a pc to work with Construct for quite a while.

But you really don't need another behavior, just use events that take over control as soon as the car behavior needs tweaks.

Your idea is what I would do, too. Adjusting the speed, via 'Set speed'. Do it over time (n * TimeDelta). And keep in mind, that when bouncing, all values are expressed negative. If you don't want the car to go backwards, but rather slow down against zero, just reverse 'Get Speed' with abs() in the 'on bounce'-event.

+ On bounce
-> car: Set speed to Abs(expression for get speed) - n * TimeDelta

n being pixels per second, e.g. 'Get deceleration'
This would decelerate linear and only when bouncing, making sense only when hitting another car for several ticks. It's just a simple approach to point to the right direction. For more detail I would need to work with Construct. I'm sorry.[/quote:yfu0o7gh]

No problem, any help at all written or example form is helpful especially since I am attempting to slowly learn the functions and methods used within Construct. Getting used to the interface, available functions etc. is going to take some time. Thanks for the help tulamide. :wink:
B
2
G
1
Posts: 37
Reputation: 524

Post » Mon Jun 13, 2011 6:25 pm

this is probably a useless hint,but with some work u could get a decent car movement with physics behavior. i once tried to do it,and almost managed,but i couldnt figure out how to make proper steering..(i could only steer/turn when accelerating,didnt find any way to make it right. mind you though,im just a beginner,im sure someone with more experience could pull it off)
B
4
S
2
G
2
Posts: 109
Reputation: 1,318

Post » Mon Jun 13, 2011 6:56 pm

[quote="clodius666":35zfncw5]this is probably a useless hint,but with some work u could get a decent car movement with physics behavior. i once tried to do it,and almost managed,but i couldnt figure out how to make proper steering..(i could only steer/turn when accelerating,didnt find any way to make it right. mind you though,im just a beginner,im sure someone with more experience could pull it off)[/quote:35zfncw5]

That's a option I considered but for now I am trying to keep things simple enough without becoming to dull. I am still playing with all the options though so I may start looking at some physics behavior in the near future.
B
2
G
1
Posts: 37
Reputation: 524

Post » 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

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests