Stuck on some sort of formula needed
JamesZeppelin
Member Posts: 1,927
Ok so here is my issue.
I have this lady bug that moves around much like the way a ball does in labyrinth game.
However i want him to point the direction he is going.
i attached rotate to angle and figured just pointing in one of four directions would be ok.
It looked fine on the mac simulating the moves with the arrow keys however when i put in on the iphone he just gets kinda squirrelly. seems to point left and right ok but up and down dont work so well
I was wondering if there is some sort of formula that could be put in to make him always point in the direction he is moving.
I know thats alot
I have this lady bug that moves around much like the way a ball does in labyrinth game.
However i want him to point the direction he is going.
i attached rotate to angle and figured just pointing in one of four directions would be ok.
It looked fine on the mac simulating the moves with the arrow keys however when i put in on the iphone he just gets kinda squirrelly. seems to point left and right ok but up and down dont work so well
I was wondering if there is some sort of formula that could be put in to make him always point in the direction he is moving.
I know thats alot
Comments
Every .1 seconds
Change self.position2X to self.position1x
Change self.position1X to self.position.X
Change self.position2Y to self.position1Y
Change self.position1Y to self.position.Y
Constrain self.rotation to VectorToAngle (self.position1X-self.position2X , self.position1Y-self.position2Y)
I just thought this up. Haven't tried it. But the idea is that every 0.1 seconds you are figuring out the angle between the point on the screen at the beginning of the 0.1 seconds and at the end of the .1 second interval.
I haven't really got my head around vector to angle yet but I'll plug ghat in and see what happens
thanks
I'll report back later tonight
Constrain self.rotation to VectorToAngle (self.position1X-self.position2X , self.position1Y-self.position2Y)
constrain attribute self.rotation = vectorToAngle(self.motion.linearVelocityX, self.motion.LinearVelocityY)
done.
I think i follow that
Ill plug it in and see what happens
His turning speed even keeps up with his movement speed.
I noticed it also helps because when you bump into a wall it snaps his towards teh direction you are going to make it a little easier to control!!
thanks man
there was no timer invlolved
I actually didnt even need to use the velocity rule he suggested.
the only thing i used was
constrain attribute:
self.rotation = vectorToAngle(self.motion.linearVelocityX, self.motion.LinearVelocityY)