Touch and Drag question
AfterBurnett
Member Posts: 3,474
Hi guys,
The game I'm working on requires a "touch and drag" control method. I used this for Max Vector but what I need for this game needs to have a limited speed. Kinf of like the game "Racer" (which, by the way is absolutely brilliant - check it out!).
For example, I want to be able to drag my finger and the object follows but at a set maximum speed... it shouldn't "keep up" with the player's finger. I also don't want it to jump or warp to wherever the player places their finger.
How would I go about doing this?
Cheers
The game I'm working on requires a "touch and drag" control method. I used this for Max Vector but what I need for this game needs to have a limited speed. Kinf of like the game "Racer" (which, by the way is absolutely brilliant - check it out!).
For example, I want to be able to drag my finger and the object follows but at a set maximum speed... it shouldn't "keep up" with the player's finger. I also don't want it to jump or warp to wherever the player places their finger.
How would I go about doing this?
Cheers
Comments
I've tried it with "move to" and it works perfectly, very smooth... only when it reaches its destination, you have to remove your finger and press down again to start the sequence off again. I need it so that it's constantly following your finger...
Wrap it in a when touch is pressed rule.
Obviously this will force you to unlock an instance to get to the scene camera.
I took this from the wiki page about how to have an actor follow the mouse and changed it to the accelerate toward to do what you are talking about.
I would also then set the max speed. I like a max speed around 300 and a high acceleration to make the angle changes responsive. You could probably work out a Touch Racing system by using magnitude between the player and the touch coordinates so that the farther away your finger is the faster it accelerates. Just a thought.
Create a timer so that every 0.01 seconds, the actor moves to the touch x and y continuously.
hope it helps!
I didn't realize you needed it to stop when you release when I suggested that approach.
http://gamesalad.com/game/play/72498
Just like in Racer, you guide the car with your finger but it won't keep up if you move super fast (othrwise it would be unrealistic).
just a thought.
Then Wrap the above rules in
When self.DistanceFromFinger > 20 (or whatever feels right)
OTHERWISE
Change attribute linear drag to 2000
Change attribute linear.motionX to 0
Change attribute linear.motionY to 0
Or put the otherwise changes in the otherwise of the When touch is pressed rule (or both!)
Something like that
When you want it to stop it spawns a copy of itself and destroys itself.
I can't believe you didn't think of MAX speed!
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Rule
When self.distanceFromFinger is <5
change attribtue maxspeed to 0
OTHERWISE
change maxspeed to 300(or whatever)
does that work?