Prevent velocity...?
As_Of_Latte
Member, BASIC Posts: 343
I have an actor:
-When touch is pressed (anywhere on the screen),
-change the velocity of this actor, to direction 90 at speed 325 ("boost up")
I've set up a rule for gravity, using:
-Accelerate direction 270 at speed 300 ("float down")
My question is; how would I prevent this actor from "boosting up" when touching/pressing another actor on the screen? This second actor I am using to touch/spawn a power up and I do not want my original actor to "boost up" during this interaction...
I'm sure there is something simple I'm overlooking, but, any help would be greatly appreciated Thanks!
Comments
Should't when touch is pressed mean it will happen only if you press on the actor the rule is in? Unless you've set something up to do it where it's anywhere on screen I guess. If that's the case, then I guess I would include a boolean in the other actors you want to touch. When they're touched, have them change a game level boolean.
So in your powerup actor
If
-touch is pressed
then
-change game.poweruptouched to true
otherwise
-change game.poweruptouched to false
In your hero actor,
If
-touch is pressed
-game.poweruptouched = false
Then
-Change velocity
Vote for Nearest Neighbor Scaling option in gamesalad! Let's make our games look truly stunning!
@owen_dennis Ahhh...that makes perfect sense! Your first sentence helped me realize the issue...
Within my hero actor, (that can "boost up" and "float down") I am using the rule:
-When MOUSE BUTTON is DOWN
-change the velocity of this actor, to direction 90 at speed 325.
And within my power actor, I am using the rule:
-When TOUCH is PRESSED
-spawn powerup
You're completely correct and I guess this is how I am allowing my hero actor to "boost up" when the player taps anywhere on the screen...
I can see where the issue is now, however, I still can't figure out how to fix it . Your game boolean is the perfect solution (if me hero actor is set to TOUCH/PRESSED) however, then my hero is unable to "boost up" when tapped anywhere on the screen.
Hope this makes sense. Let me know if you have a solution! I'm stumped
You might want to rethink the touch anywhere control. Do you have a jump button? You could always add code to the jump button to jump higher when the power up is active.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
You have a few options here.
You could change how you boost the character up. Currently you're using mouse button is down, but you could solve this by changing that to a touch on an invisible actor, and adding a layers check. This would be pretty simple to do.
You could leave the boost mechanic the same, but have it check mouse position, and have it specifically exclude the area of the button. It would be a few extra conditions, but nothing problematic.
You could do what @owen_dennis suggests and use an attribute to track when the power button is pressed. This would most likely work, but would possibly lead to a slight lad in the actor moving as you'd have to ensure the power up attribute had time to change first.
You could allow touch only on the bottom part of the screen. This is similar to 2, but fewer conditions as you just remove the ability to touch anywhere on the screen from the Y position of the bottom of the power-up.
I'll send you a demo.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Lost_Oasis_Games Awesome suggestion, thanks! Unfortunately, my game doesn't have a jump button...it's a little fast pace too, which is why I allow the player to press anywhere on the screen, to avoid missing a designated jump button. I appreciate the feedback
@Armelline Thank you! I know you're super busy so I didn't want to bother with such a small task, but your touch demo works perfect! I appreciate you taking the time to help and quick response!