Problems with Simulate Car Control

Get help using Construct 2

Post » Tue Oct 11, 2016 4:22 pm

Hi All!

I'd like to ask a question, since my game crashes in very peculiar circumstances.

I'm using Simulate Control for a top-down car-based game. However, when I am breaking and steering at the same time, the sprite I use for the player crashes. Now, there's some backstory to this.

I have events with the following conditions (among others, but I think these two conflict in some way):
1. Down arrow is down && Car speed <= 0 : Set Car max speed to 0
2. Right Arrow is down : Simulate Car pressing Steer right
3. Left Arrow is down : Simulate Car pressing Steer left

Could the steering conflict with the max speed = 0 thingy?

Thanks in advance!
Last edited by dastmo on Wed Oct 12, 2016 3:39 am, edited 1 time in total.
B
8
S
2
G
3
Posts: 18
Reputation: 2,036

Post » Tue Oct 11, 2016 8:12 pm

Crashes, like it shuts down? Or the sprite is displayed incorrectly? I'm not sure how this would be caused by those events.

But as for the events themselves, your first event effectively turns off movement. If you set "Car MAX speed" to 0, it means the sprite's top speed is 0, i.e. it's not going to move. IIRC with car behavior, if you're not moving then it's not going to turn either, so it'll just sit there. You want to set current speed to 0 and leave the max above 0.
B
50
S
23
G
17
Posts: 291
Reputation: 12,432

Post » Wed Oct 12, 2016 3:37 am

Message: dastmo can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Crashes like, the car sprite bugs out, displays at its default angle until the next button press, which would modify the car's movement. The next button pressed makes the game destroy the car instance.

The max speed thingy is a workaround for a simple gears system. I'd like the car to go back, only when it's in reverse gear and the Up Arrow is pressed. So, to do that I have the following condition:

- Down arrow is down && Car speed <= 0 && gear (instance variable) <= 1 : Set Car max speed to 0

Once the down arrow is released, though, the car's speed is reset every tick. So, basically, while brakes are being pressed, max speed = 0. While not - max speed is reset every tick.

Would there be a better way to disallow the car to move back without being in reverse gear?

EDIT: I actually found a solution. Steering is now being simulated only if speed > 0. When the max speed = 0 and steering is active, the instance bugs out, so I implemented the speed check.

EDIT 2: The first edit still had flaws. But I made it happen! And it works flawlessly with a completely different approach. I don't mess with max speed, but with acceleration, deceleration and current speed. Link to the event sheet below (top three are in System Every Tick):
https://goo.gl/Xu1qmr
B
8
S
2
G
3
Posts: 18
Reputation: 2,036


Return to How do I....?

Who is online

Users browsing this forum: bluesun66, Kenthria, Malhog, plinkie and 1 guest