Hey, I just wanted to thank you for all the awesome advice you've given me. It's really been a huge help. Without you my app would not be nearly as smooth and fun. It's great that you take time out of your day to help me. Thank you.
And (As Usual)...
Question: How would I make a paddle that rotates facing outwards towards your finger. However, it does not move, it only rotates. The long side pointing toward you finger. I have had this mode for awhile now, but I need it to look as smooth as the other two. There are three modes, this one, the arc motion one and the flat one.
@SnapFiresaid: Hey, I just wanted to thank you for all the awesome advice you've given me. It's really been a huge help. Without you my app would not be nearly as smooth and fun. It's great that you take time out of your day to help me. Thank you.
No problem. I've asked these very same questions (with different software). The really great thing about GameSalad is that you can just get on with working out the solution without all sorts of programming language syntax to get in the way.
The answer to pivoting a stationary actor towards the mouse is pretty much the same for the other two questions. The general formula for these kinds of 'tracking' tasks is: newState = currentState + (targetState - currentState)*dampingFactor
So, the solution is pretty much the same -- stripped down to its bare essentials it looks like: self.Rotation = self.Rotation + (AngleToTheMouse - self.Rotation)*.1
When all the extra stuff gets added to it -- it looks like:
When mouse is down: ----Constrain Attribute self.Rotation To: min(180,max(0, self.Rotation +((((vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )- self.Rotation )+180)%360)-180)*.1))
Hey. I haven't tried what you said yet, but I am trying to import PNG's into my game. I've had this problem ever since the latest update. But off and on. It seems that illustator documents exported to png's work fine, but photoshop files saved as png's are very blurry, and about a fourth of the expected size. This has nothing to do with the percent i'm viewing in photoshop, or the size being to small. I used to have this problem, but it's gone away for awhile. Also, all of the images are proportioned in even numbers, and the same proportion as the original. Any Ideas?
So I don't want any min or max on this one, so I edited what you gave me and got: self.Rotation +((vectorToAngle( game.Touches.Touch 1.X - self.Position.X , game.Touches.Touch 1.Y - self.Position.Y )- self.Rotation )*.06)
However, it seems to move in the opposite direction of where i click for about a second before stopping. Weird. Also, i'm sure it's in a constrain rule withen a rule that checks for mouse button down. Any ideas?
Hey -- 1) Graphics -- can't help with graphics (don't know anything about graphics -- pretty sad).
2) Accelerometer -- you might try using the same idea for using them. Something like: When accelerometer.Y < -.01 ---- constrain self.targetAngle to 180 otherwise ---- change self.targetAngle to self.rotation
When acceleromenter.Y > .01 ---- constrain self.targetAgnel to 0 otherwise ---- change self.targetAngle to self.rotation
That way when the device is tilted to the left it starts to rotate towards the left, but when its set back to level, the paddle just sits there.
3) Not sure why its moving in the opposite direction. You might need to change one of the operations from addition to subtraction (or the other way around.) Or do you mean that its overshooting the target angle? (It goes too far and has to correct itself?)
What I mean by opposite direction is that it shoots in the oposite of your touch (reflection across y axis) at the beggining, then won't move. I'm looking into how other actor may be causing this now.... There's nothing wrong with what I entered, right? (I put it above)
Hey, I just realized that the flat level actually isn't working. For some reason, the paddle is moving away from where you touch. (Not like it did in the curved one) Wherever you press, it moves in the other direction. Very odd. Also, it stops as soon as you let go immediately. I tried butting the whole equation you gave me in parenthesis and putting a negative sign before it, but that just made it jittery. Do you have any idea what's going on?
I just remembered a fun little equation that might be useful for the accelerometers control. This one calculates gravity -- which way is down. I used it for a making a picture (hanging on a wall) swing like a pendulum. You would use it in just the opposite way.
You can use it to do the opposite of gravity. Then it just adjusts self.targetAngle like the rest of the equations.
To find which way is "down" use VectorToAngle(accelerometer.x, accelerometer.y).
It would look like this for the way you have things set up: Constrain Attribute: self.targetAngle To: min(180, max(0, self.targetAngle +(((vectorToAngle( game.Accelerometer.X , game.Accelerometer.Y )-90)%360)- self.targetAngle )*.1))
The "-90" is for adjusting things if the device is in landscape mode. It it is in portrait its probably "-180".
So first of all, that won't work in the flat level, and i haven;t tried it in the point toward touch level. In the arc level, it just causes it to jitter back and forth between 180 and 0. And yes, i'm constraining targetangle, just like you said. Also, I don't understand how that would work. They'd be fighting each other, but cause when one is off the other is on, and since the otherwises of both don't match with the regular space of both, then they'd be fighting for control. Just in case i tried just getting ride of the otherwises's but same result: no movement.
Let me know if you come up with something. (also, I have changed so that the app will be released thursday night, so I have until then to get this fixed.)
Finally! I got it! I just reversed the equation and it worked. Not really sure why it had to be reversed, but it works! Now all I need is fix are the accelerometer, which is still not doing anything, and the point toward touch level.
ARG! The level where the paddle stays in one place still won't work. It works perfectly for about 1.5 seconds, then just stops moving. No other rules are interferring. I tried putting a change attribute inside a time instead, but that just makes it worse....
I'll PM you in about 30 min. I want to finish up with what i'm doing. I assume I copy the url I have when I'm in the folder containing the gameproject folder? Also, if you download the folder, can you open it in GameSalad, or do I need to somehow get you the actual .gameproj file?
Right -- the new accelerometer idea replaces all the other accelerometer stuff.
Try this (in the arc level)
when mouse is down ---- Constrain Attribute self.targetAngle To: (the regular formula) otherwise ---- Constrain Attribute: self.targetAngle To: min(180, max(0, self.targetAngle +(((vectorToAngle( game.Accelerometer.X , game.Accelerometer.Y )-90)%360)- self.targetAngle )*.1))
It worked perfectly, however it made my paddle orbit around (0,0) instead of the bottom center. How would I get that back? Other than that - Outstanding. Very smooth.
So, what's left: Touch for level where paddle stays in the same place and rotates to touch Accelerometer for that level as well Accelerometer for the flat level.
I imagine that for the flat level, you'd do the same thing. Replace the touch.x with accel.x There's probly some other thing i've got to do to. Trying it now anyway.
Yeah, I obviously need something else in the flat level. It is going really fast one way (I have a wrapped x screen), stopping at the edge, then going really fast agin to get to that edge again... weird. -Thomas
Orbiting around 0,0......? Did you include the three constrains at the top (before the "When mouse is down")? Constrain self.Position.X Constrain self.Position.Y Constrain self.Rotation
Comments
And (As Usual)...
Question:
How would I make a paddle that rotates facing outwards towards your finger. However, it does not move, it only rotates. The long side pointing toward you finger. I have had this mode for awhile now, but I need it to look as smooth as the other two. There are three modes, this one, the arc motion one and the flat one.
Thanks Again!
-Thomas
The answer to pivoting a stationary actor towards the mouse is pretty much the same for the other two questions. The general formula for these kinds of 'tracking' tasks is:
newState = currentState + (targetState - currentState)*dampingFactor
So, the solution is pretty much the same -- stripped down to its bare essentials it looks like:
self.Rotation = self.Rotation + (AngleToTheMouse - self.Rotation)*.1
When all the extra stuff gets added to it -- it looks like:
When mouse is down:
----Constrain Attribute self.Rotation To: min(180,max(0, self.Rotation +((((vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )- self.Rotation )+180)%360)-180)*.1))
Hope this helps
RThurman
-Thomas
self.Rotation +((vectorToAngle( game.Touches.Touch 1.X - self.Position.X , game.Touches.Touch 1.Y - self.Position.Y )- self.Rotation )*.06)
However, it seems to move in the opposite direction of where i click for about a second before stopping. Weird.
Also, i'm sure it's in a constrain rule withen a rule that checks for mouse button down. Any ideas?
-Thomas
-Thomas
PS. Tese are the finishing touches on my game, which has to be published tonight. Any help is appreciated.
1) Graphics -- can't help with graphics (don't know anything about graphics -- pretty sad).
2) Accelerometer -- you might try using the same idea for using them. Something like:
When accelerometer.Y < -.01
---- constrain self.targetAngle to 180
otherwise
---- change self.targetAngle to self.rotation
When acceleromenter.Y > .01
---- constrain self.targetAgnel to 0
otherwise
---- change self.targetAngle to self.rotation
That way when the device is tilted to the left it starts to rotate towards the left, but when its set back to level, the paddle just sits there.
3) Not sure why its moving in the opposite direction. You might need to change one of the operations from addition to subtraction (or the other way around.) Or do you mean that its overshooting the target angle? (It goes too far and has to correct itself?)
Have fun with final tweaks!
RThurman
What I mean by opposite direction is that it shoots in the oposite of your touch (reflection across y axis) at the beggining, then won't move. I'm looking into how other actor may be causing this now.... There's nothing wrong with what I entered, right? (I put it above)
-Thomas
Is this for the paddle that points toward the touch, right? (Not the ark one, and not the flat one, right?)
-Thomas
-Thomas
One of the things you can do is to reverse the first operation. Instead of self.targetAngle + (......) change it to "self.targetAngle - (.........)".
You can use it to do the opposite of gravity. Then it just adjusts self.targetAngle like the rest of the equations.
To find which way is "down" use VectorToAngle(accelerometer.x, accelerometer.y).
It would look like this for the way you have things set up:
Constrain Attribute: self.targetAngle To: min(180, max(0, self.targetAngle +(((vectorToAngle( game.Accelerometer.X , game.Accelerometer.Y )-90)%360)- self.targetAngle )*.1))
The "-90" is for adjusting things if the device is in landscape mode. It it is in portrait its probably "-180".
So first of all, that won't work in the flat level, and i haven;t tried it in the point toward touch level. In the arc level, it just causes it to jitter back and forth between 180 and 0. And yes, i'm constraining targetangle, just like you said.
Also, I don't understand how that would work. They'd be fighting each other, but cause when one is off the other is on, and since the otherwises of both don't match with the regular space of both, then they'd be fighting for control.
Just in case i tried just getting ride of the otherwises's but same result: no movement.
Let me know if you come up with something. (also, I have changed so that the app will be released thursday night, so I have until then to get this fixed.)
Thanks a lot,
-Thomas
-Thomas
Now all I need is fix are the accelerometer, which is still not doing anything, and the point toward touch level.
-Thomas
-Thomas
Not sure what I can tell you about the pointer one. Strange that its working for 1.5 seconds then stopping.
I'm am loosing track of which thing is being described. You (and I) will need to be very clear about which level is being described.
I assume I copy the url I have when I'm in the folder containing the gameproject folder? Also, if you download the folder, can you open it in GameSalad, or do I need to somehow get you the actual .gameproj file?
Thanks,
-Thomas
-Thomas
Try this (in the arc level)
when mouse is down
---- Constrain Attribute self.targetAngle To: (the regular formula)
otherwise
---- Constrain Attribute: self.targetAngle To: min(180, max(0, self.targetAngle +(((vectorToAngle( game.Accelerometer.X , game.Accelerometer.Y )-90)%360)- self.targetAngle )*.1))
It worked perfectly, however it made my paddle orbit around (0,0) instead of the bottom center. How would I get that back?
Other than that - Outstanding. Very smooth.
So, what's left:
Touch for level where paddle stays in the same place and rotates to touch
Accelerometer for that level as well
Accelerometer for the flat level.
I imagine that for the flat level, you'd do the same thing. Replace the touch.x with accel.x
There's probly some other thing i've got to do to. Trying it now anyway.
-Thomas
weird.
-Thomas
Constrain self.Position.X
Constrain self.Position.Y
Constrain self.Rotation
When mouse is down:
---- Constrain Attribute: self.Position.X To: self.Position.X -( self.Position.X - game.Mouse.Position.X )*.1
Otherwise
---- Constrain Attribute: self.Position.X To: self.Position.X -( self.Position.X -(240+ game.Accelerometer.Y *240))*.1
This assumes that your device is 480 pixels wide. If its an iPad then it would be 512 (instead of 240)