How do I make a button accelerate my actor (car)?

I'm trying to make a button accelerate the car. How do I make it so when I press the button on the screen it accelerates the car forward? How do I connect the two?
btw I have the button on the screen and the car rotates with my joy stick, but how do I make it so the button accelerates it? (also it would be great if you could also tell me how the other button brakes the car)
btw I have the button on the screen and the car rotates with my joy stick, but how do I make it so the button accelerates it? (also it would be great if you could also tell me how the other button brakes the car)
Best Answer
-
JohnPapiomitis Posts: 6,256
You connect the two with game attributes.
Make a game attribute called go, make it a boolean.
In your button have when touch is pressed
-change attribute go to true
Then in the otherwise section of that rule put a change attribute behavior and change attribte go to false.
Then in your car have a rule when attribute go=true
-accelerate
Answers
http://imageshack.us/photo/my-images/710/screenshot20120323at737.png/
this one is for the button
http://imageshack.us/photo/my-images/851/screenshot20120323at737.png/
did I do it correctly?
In your button:
Rule: When touch is pressed
-change attribute game.go to true
OTHERWISE
-change attribute game.go to false
In your car:
Rule: when attribute game.go=true
-accelerate behavior
http://imageshack.us/photo/my-images/546/screenshot20120323at100.png/
And the car rule is good now
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Translation:
A) Here's the code for my button and car - are they both right ?
A) Ok . . you know my code for the button which you said was wrong . . .
A) Well, I kept that wrong code and guess what . .
A) It still doesn't work.
Rule: when
Event: touch is pressed
--changeAttribute: game.accelerate To: true
Otherwise:
--changeAttribute: game.accelerate To: false
on Car:
Rule: when
Attribute: game.Accelerate = true
--accelerate behaviors (as @FryingBaconStudios instructed)
Otherwise:
--stop behaviors
Car:
http://imageshack.us/photo/my-images/714/screenshot20120324at105.png/
Button:
http://imageshack.us/photo/my-images/542/screenshot20120324at105.png/
In your button all is good, except you need a change attribute behavior in the main part of the rule as well, changing attribute.go to true. Leave the otherwise section how you have it.
Attribute____self.Physics.Drag____=____0
??
Also for future references, you cant change an actors physics atttributes in game with a change attribute behavior or anything.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS