(Solved) Custom Car Movement

This forum is currently in read-only mode.
From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
  • 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!

  • 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.

  • 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.

  • 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.

    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.

  • 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.

  • 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.

  • 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.

    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.

  • 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)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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)

    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.

  • [quote:19l9tmek]+ On bounce

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

    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.

  • 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.

  • 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.

    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!

  • 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

    http://www.mediafire.com/?4564i6b96dylaga

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)