My rotation is jumpy

I fix the other problem.
When I press UP it rotates counter-clockwise and if I keep the button pressed it moves normal. If I release the button and then I pressed again it may start in the position it was but sometimes it start in a different position on the rotation. The same happens when I hit Down.
When I press UP it rotates counter-clockwise and if I keep the button pressed it moves normal. If I release the button and then I pressed again it may start in the position it was but sometimes it start in a different position on the rotation. The same happens when I hit Down.
This discussion has been closed.
Comments
The formula I am using is:
(To move counter-clockwise)
when all conditions are valid
actor receive event key up
constrain: self.Position.X to 100*cos(self.Time*300%360)+240
constrain: self.Position.Y to 100*sin(self.Time*300%360)+160
constrain: self.Rotation to vectorToAngle(240- self.Position.X , 160- self.Position.Y )
(To move clockwise)
when all conditions are valid
actor receive event key Down
constrain: self.Position.X to 100*cos(self.Time*-300%360)+240
constrain: self.Position.Y to 100*sin(self.Time*-300%360)+160
constrain: self.Rotation to vectorToAngle(240- self.Position.X , 160- self.Position.Y )
I will be posting this on "My rotation is Jumpy" too. Almost every time I try to hit the ball, the pad appear in another place on the rotation.
Thanks again.
Come to think of it, you might want to just make a set of custom attributes for myPositionX, myPositionY, and myRotation. Then when you click up or down, first set it to the desired position and rotation using the new attributes, then have it start to do the moving.
Can you give me a little more details. Like what kind of attributes (interger, real,etc) for myPositionX, myPositionY and myRotation. Then for the setting of the desired position and rotation, where should I do this, should I substitute some of the formula or I have to insert a behavior?
Thanks again
Can you email me a project file? davey at a3mg dot com
The problem is that when i press the button to move sometimes it jumps to another position in the circle and i miss the ball.
I made a similar example here and see the issue. I'll see what I can come up with.
I will be here.
thanks
On my version, when changing direction it seems good if I am close to the Y midline (y=160 or at 9o'clock and 3'oclock)
When the paddle is at 12o'clock it jumps to 6o'clock when changing direction and opposite when the paddle is at 6'o'clock and I change directions it jumps to 12o'clock.
This definitely has to do with the sin and cos equations.
I am still looking into this. Anyone else want to chime in?
What I did was:
Create 2 actors: 1 invisible and 1 visible which is the pad to hit the ball. The invisible will be the rotator. The rotator will have a Rule to Rotate counter-clockwise with the press of Up and another Rule to Rotate clockwise by pressing Down.
The pad will be constrain to the Rotator position with the cos and sin formula and also it will have an Rotate To Angle to maintain its orientation.
And with all this the pad travels smoothly Counter and Clockwise thru the entire rotation.
Thanks A3MG for all the help and all the patient I really appreciate it.
IRXPosition
IRYPosition
And one angle attribute:
IRRotatorAngle
1st Constrain attribute:
self.position.X To game.IRXPosition +cos(game.IRRotatorAngle %360)*150
2nd Constrain attribute:
self.position.Y To game.IRYPosition +sin(game.IRRotatorAngle %360)*150
Rotate to Angle:
Angle: game.IRRotatorAngle Relative to: scene
Speed 300 ( don't check any of the boxes)
The Rotator is Constrained in this way
game.IRRotatorAngle to self.Rotation
game.IRXPosition to self.Position.X
game.IRYPosition to self.Position.Y
And then apply the movement with a rule to press up and Rotate Counter and so on
Very simple but hard to find. I found some examples that game me the idea in a chainsaw tutorial
What I did was for the pad/paddle was have the following
self.Position.X = IRXPosition
self.Position.Y = IRYPosition
Then the same vector to angle that was used before -
Constrain: self.Rotation To: vectorToAngle(240- self.Position.X , 160- self.Position.Y )
I put the sin/cos calcs on the rotator
Constrain Attribute: IRXPosition To: 140*cos(self.Rotation)+240
Constrain Attribute: IRYPosition To: 140*sin(self.Rotation)+160
I might make something with this, will be fun to see what we both come up with.
You are using self.time inside your trig functions to calculate the x and y position.
Time passes while you are not pressing your button. When you press the button again the object teleports to the new position because at the time the button is pressed is when the cos and sin calculations are performed. The reason that it moves smoothly while you hold the button down is because small moments are ticking by on the clock and you see the x and y positions recalculated over a very small distance. This results in the apperance of smooth animation.
To fix your problem you need to use the Move behavior.
rule up pressed
change attribute self.rotationDirection = 1
rule down pressed
change attribute self.rotationDirection = -1
// point towards the center of the screen
Constrain Attribute: self.rotation = vectorToAngle(270-self.position.x, 160-self.position.y)
// move left and right relative to the actor
Move: Angle: 90 (actor), Speed: self.rotationDirection * 100
I resolved my problem but I think that your answer is a lot simpler.
This is what I don't know were to put:
// point towards the center of the screen
Constrain Attribute: self.rotation = vectorToAngle(270-self.position.x, 160-self.position.y)
// move left and right relative to the actor
Move: Angle: 90 (actor), Speed: self.rotationDirection * 100
When the paddle is at 12o'clock it jumps to 6o'clock when changing direction and opposite, when the paddle is at 6'o'clock and I change directions it jumps to 12o'clock.
But like you say if I keep it pressed It keep going without the teleportation.
I created a rule when all conditions are valid: actor receives, key, Up.
Constrain attri: self.Position.X To 100*cos( self.Time *400%360)+240
Constrain attri: self.Position.Y To 100*sin( self.Time *400%360)+160
Change Attr: self.Rotation To 1
Another rule when all conditions are valid: actor receives, key, Down.
Constrain attri: self.Position.X To 100*cos( self.Time *-400%360)+240
Constrain attri: self.Position.Y To 100*sin( self.Time *-400%360)+160
Change Attr: self.Rotation To -1
Then, not in a rule I put:
Constrain Attri: self.Rotation To vectorToAngle(270- self.Position.X ,160- self.Position.Y )
Move Direction 90 relative to actor, additive, Speed self.Rotation *100
I know its wrong because is not working, it keeps teleporting.
Can you see where or what is my mistake?
I created a rule when all conditions are valid: actor receives, key, Up.
DELETE THIS
----
Constrain attri: self.Position.X To 100*cos( self.Time *400%360)+240
Constrain attri: self.Position.Y To 100*sin( self.Time *400%360)+160
-----
~ This is not what i wrote ~
Change Attr: self.Rotation To 1
~ this is wrong too ~
Another rule when all conditions are valid: actor receives, key, Down.
Constrain attri: self.Position.X To 100*cos( self.Time *-400%360)+240
Constrain attri: self.Position.Y To 100*sin( self.Time *-400%360)+160
Change Attr: self.Rotation To -1 <--- this is totally not what i said
~ this IS correct ~
Then, not in a rule I put:
Constrain Attri: self.Rotation To vectorToAngle(270- self.Position.X ,160- self.Position.Y )
~ this is almost correct, I didn't say to set the speed to the rotation times 100. Read what I wrote.
Move Direction 90 relative to actor, additive, Speed self.Rotation *100
Read what I wrote again. It's not what you wrote.
Only use the code i wrote in the post above, don't add your own to it. I didn't say to constrain any x or y position.
self.rotationDirection is a variable that i made up. It's not self.rotation which is a system variable. You have to create an actor variable self.rotationDirection (integer).
ps
sorry if my tone seems harsh. It's nothing personal. I haven't slept and i'm in a hurry so I haven't taken the time to edit this for politeness.
ps
And this is me taking the 10 seconds to edit for politeness.:)
Thanks
Aaron
--Closed