Touch controls without any buttons involved?
ohtukrw
Sir dogeMember Posts: 106
How do I make the actor accelerate where the touch is based on the x axis?
Comments
It's not really clear what you're asking. Is the acceleration to be controlled by how long someone taps/clicks within a certain area or by how low/high the touch X position is?
For the latter, you would use the mouse position (game.mouse.position.X and game.mouse.position.Y).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Two generic guidelines:
1. "Help Wanted" is for people who want to post to pay people for game development, art, or post their availability to work; you may want to change the topics you keep posting under as "Working With GS"
2. If you Google search your question with "Gamesalad" before it, it is a lot easier to find answers on these forums than the forum search above. It may help you out more
Back to Question answering:
Not sure what "touch is based on the x axis means". Do you want to "swipe" on the x axis? or just touch somewhere on a specific horizontal line?
Touch once without the longevity of the touch involved. > @tatiang said:
I want the hero to accelerate left or right (x axis) where the touch is pressed once (without touch longevity involved)
What would be the full rule please? As English is not my native I struggle with the different function meanings.
Create a boolean call it accelerate
if touch is pressed
change attribute accelerate to true
if attribute self.accelerate is true
accelerate right or left
This way it wont depend on touch longevity , but it will accelerate so the speed will increment , you can have a max speed if you want , or use change attribute self.motion linear velocity x.
This is still a little confusing . . . is the direction (left or right) chosen randomly when you touch the actor ?
Sorry, my bad wording.
When players touched outside the actor (main hero) anywhere on the screen, to determine where the actor should accelerate to, affecting only x linear movement.
hmm
Here just give it a number and tick apply max speed
@ohtukrw If you want the touch to be anywhere on the screen do
if mouse button is down instead of if touch is pressed
I attached a demo if you want , im sure there is an easier way to do it.
Hope it helps
you are amazing
TL;DR Solution found
Long:
Well I have tried your complex rules and it didn't work.
Because my game already has accelerate in direction 0. And your rule triggers either left or right acceleration on touch, it eliminates other movement rules, which is in my case.
The way I set up my computer keyboard controls, which work is:
self.motion.linearvelocity.x to - or + direction and is accordingly set up to execute once, when the necessary key is pressed, that way my accelerate in direction 0 rule isn't affected and the hero travels without pressing anything.
People mentioned game.mouse.position.x, so it took me some frowning until this happened:
when
game.mouse.position.x<self.position.x
mouse down
do accelerate direction 180
and vice versa, which are more simplistic.
I will try to add self.motion.linearvelocity.x instead of accelerate like I did on the keyboard, hopefully it works.
Grey matter gained +1 xD
Why is the hero jerking back and forth when touched at right side?
http://www33.zippyshare.com/v/sgA1gPWv/file.html
You can simplify this same idea, delete all the rules and replace them with . .
When mouse button is down:
--Accelerate / Direction V2A(mouse X - self X, 0)
Unlock Actor 1 . . . delete your touch right and touch left rules . . . and replace them with this one rule:
It's not clear why you have an Accelerate (right) behaviour and a Liner Velocity (right) too . . . ? If you switch off the Linear Velocity (right) behaviour it makes no difference to the project.
My project is a hero jumping and is moving relative to the scene. I want it to move forward all the time, so it has to be affected by some force, which is accelerate to 0 direction. Linear velocity is for controls when it is falling down, or jumping up in the air to avoid obstacles. Any other movement type would mess up the feel of the fall. Imagine a bouncing ball which moves forward all the time. The movement idea is working perfectly with computer keyboard keys, however it keeps jerking when implemented into touch
He wants it so that when you touch once it accelerates at full speed , your method can be done but you have to keep pressing , if you touch the screen once it accelerates slowly , so thats why the rule i put was complex and not simplified. If he was to use motion linear velocity it would have been easier. But i learned something new with this thanks , you always surprise me with your simplified behaviors
Did you try my suggestion above ?
Ah! I didn't realise that's what was wanted.
If you wanted it to keep accelerating when the mouse is released you could use this:
When mouse button is down:
--Change D to V2A(mouse X - self X, 0)
Accelerate / Direction D
Problem fixed thank you.
Problem fixed. Thank you
Actually fixed the problem ,thank you everyone who posted. Fixed the jerking with the -scene.camera.origin.x socks have provided. Can lock this thread
If someone is interested for a bouncing ball with touch controls, here is the final link:
http://www23.zippyshare.com/v/i0h1YyME/file.html