Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Car system

dani3

Member

I was trying to create a car system with accelleration (there are couple of scripts out there but they don't work with the custom ones I use), in which for instance you accelerate and move forward by pressing up, break by pressing x, move backward by pressing down, turn 45 degrees left while pressing left and turn 45 right by pressing right.

The problem is that it's not possible to turn 45 degrees left or right, so I tried with a gimmick, when everytime button left (or right) is pressed it adds 1 to variable 1 so you can gradually turns and when up is pressed it moves to the direction memorized by the variable.

Example (assuming the character is facing left):
if Variable 1=0
if button left is pressed

wait 4 frames
set mouve route: change graphic (sprite facing lower left)
variable 1=1
wait for movement completion
end
end

if Variable 1=1
if button left is pressed

wait 4 frames
set mouve route: change graphic (sprite facing down)
turn down
variable 1=2
wait for movement completion
end
end
and so on...

Then...

if Variable 1=1
if button up is pressed
set mouve route:
move down

and so on...


The problem is that the character turns just fine, but only moves when left is not pressed anymore. If I try to move by pressing up and left together (attempting to turn and move at the same time).
 
You, good man, are wasting all the thought put into this by trying to do it with events. I can only suggest you grab a tutorial on how to setup scenes, and go from there... as you basically got everything else covered already (and you'll be able to use a nice 360° turnable graphic with seamless turning).

Because this isn't the generic "I'm a dumb fuck and can't do shit, but I want to do it with EVENTS, and I want to do it NAO! And I'd much rather have YOU do it!!!!" thread at all, lemme try to help you out... depending on how you set it up (as in, a single event, or two parallel events), your problem might be the wait inbetween the event commands. Try to put the last block you gave there in a seperate, parallel process event, and see if that helps it. The other thing I can think about is you putting the forward movement in an else case, instead of at a naturally executed position.

In general, the input checking per event conditional branches isn't the most reliable way for stuff... it starts with multiple keys pressed at the same time and ends with not being able to address all keys you want at the specific frame you want. Either way, I'd suggest you to switch to scripting this, as you'll get all the more out of it in the end, plus you can be certain that there IS a solution to your problem, while you can certainly run into an unpassable obstacle in event scripting easily.
Just for the sake of mentioning it... doing a script that properly accelerates, brakes and turns a car (and by properly, I mean gradually, not 0 to max in a single frame) is not an easy thing to do even with scripting. If you want to take stuff such as oversteering/understeering, handbraking, different road conditions and states, and the like into account, you'll be facing a huge task already. What you have to note, though, is that by events, while you can theoretically do all of this, you'll be running out of performance and hair way before you're close to finished.
 
If none of the "car systems" work, I recommend using a pixel movement script that allows you to move in any direction possible. If you have RMXP, you should check out Cogwheels pixel movement script here:
http://www.huodqcxheddehxcqdouh.rmxpunl ... howfile=12

If you have VX, sorry, I can't help you. I just recently started using VX. I'm sure a simple search would help you find one though.


EDIT:
Oops, sorry about the necropost. I didn't pay attention to the date.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top