Best way to Have a Rotate to angle and then Shoot
Portyman
Member, PRO Posts: 409
I want to be able to touch the screen and have a actor rotate to that position and then fire. I have the rotate, but how should i do the fire? I have run to completion checked, but the missile fires to early. Help would be appreciated.
Thanks
Thanks
Comments
What I would do is have an angle attribute called self.shootAngle and a boolean called self.shoot
Then have a rule that says
when touch is pressed
change self.shoot to true
change self.shootAngle to VectorToAngle(self.position.X-touch1.X, self.positionY-touch1Y)
Then rotate to angle self.shootangle
rule- when self.shoot is true AND
when self.rotation = self.shootAngle
Spawn bullet (spawn angle of zero relative to actor)
change self.shoot to false
should work
I nested the 2nd rule to mAke it more efficient. Small change but I have gotten far into projects and needed the extra fps
Ie
Rule
When shoot is true
Rule
When self rotation is = to shoot angle
Thanks a bunch. This really did the job