conflicting controls
quinn221
Member Posts: 280
Hi All,
I am setting up a game where the actor climbs a ladder. I have my actor climbing up and down when using the keyboard. I added in a touch button, but can not get it to work when the keyboard commands are on.
I made two groups, keyboard commands and touch commands. The touch commands are an exact copy except I changed the scripting to match my button rules. If both sets of commands are on my actor will move up very little, but it seem gravity is pulling it down. If I turn one of them off, the on one work perfectly.
Below is a link to screenshots of the two rule groups. Let me know if you see anything that might be conflicting.
https://dropbox.com/s/d55xyruwfchorso/controls.zip?dl=0
Thanks in advance!
Comments
I always have trouble when it comes to ladders.
If no one else can help you, I suggest buying this template here from DBA (http://www.deepblueapps.com/?product=ladders).
It's cheaper (and painless) then pulling your hairs out because no one replies! (i hate that)
Set the rule to any not all
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
@Lost_Oasis_Games Thanks for the idea, but still nothing....
I have the feeling it has something to go with the gravity settings.... when the are on in both rules, my jump strength is half.
Just add a condition to each existing rule that you already had before you added the keyboard. Just add the key conditions to your touch is pressed and do all instead of any. You can delete the keyboard rules you made.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
I did try that in the beginning, but if the touch controls were part of it, it would not work
But it will work that way if both touch area and Keyboard are pressed.....i am stumped.
@quinn221 I think this is the problem
when key is down >> change linear velocity to 100 >> otherwise constrain to 0
when move contains down >> change linear velocity to 100 >> otherwise constrain to 0
they are both constraining their value to 0 when they are up , so when you have them both on , they wont work , cause one of them is telling it to constrain the velocity to 0 and the other one is telling it to move , thats why when ur using one rule it works fine , just a guess though
@quinn221 change the way you control , make 2 game attribute booleans game.up game.down
create an up actor
create a rule if " any " of the conditions are true , key up is down or touch is inside , change attribute game.up to true other wise change game.up to false .
now up will always work for both touch controls and up arrow key , then put in the rule you want if attribute game.up is true change velocity to 100 otherwise constrain to 0
this should work
@Icebox1910 I will give it a shot
Ok...Idea 1, did not work... I will try the second one now
Ok going up work perfect...but when I add in the down... the actor automatically climbs the ladder without a key command or touch command.....
we are getting closer!
@Icebox1910 OK now I am really close... the only issue is the actor will auto climb the ladder as soon as it touches the ladder... here is a link to my climb rules as well as my up actor button, the down is basically the same but with the game.down attribute
Can you take a look and see if you can see the problem.
Thanks!
https://dropbox.com/s/vq2613s777h38o3/Archive%202.zip?dl=0
@quinn221 i think you messed it up with the rules
set all of the ladder rules off , just in case this method doesnt work ,
you will need 4 rules
1-Rule 1 : if actor overlaps or collides with actor ladder change game.ladder to true otherwise change game.ladder to false
2- Rule 2 : if game.ladder is true constrain motion linear velocity y = 0
otherwise accelerate 270 ( gravity)
3- Rule 3: if game.ladder is true and game.down is true constrain motion linear velocity y to -100
4-Rule 4: if game.ladder is true and game.up is true constrain motion linear velocity y to 100
Test it and tell me if theres a problem
ok..it is about 99%.... the only issue now is that gravity pulls the actor down when not pressing the up command on both keyboard and touch pad
the character also get stuck in the climb image state, until he jumps...
Okay so the gravity issue is you need a neutral state when on the ladder so you need to constrain the actors X and Y position to the current position when on the ladder and no movements are being called. If when at the top of the ladder you need to be sure the actor returns to a default idle standing position once off the ladder. Remember logic is a series of events so think in logic when looking at your code.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Check out this template http://forums.gamesalad.com/discussion/87301/ladders-a-free-template
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
For the gravity issue, put the Accelerate Behavior that causes the gravity in a Rule like this:
If the player is on/touching a ladder
don't do anything/no accelerate behavior
Otherwise
do the accelerate behavior
This would turn off gravity while the player is on a ladder.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page