rotate THEN shoot
jonmulcahy
Member, Sous Chef Posts: 10,408
I'm working on a new game, and I need an object to rotate to face where the user touches on the screen and THEN fires a projectile. I've got the object to rotate just fine, but I'm sure how to best going about shooting once the object stops rotating.
anyone tackle this before?
anyone tackle this before?
Comments
Only start checking after the turret start rotating, so it doesn't fire right away.
Or check against the angle like synthesis suggests.
I'll give the angle method a try, as long as I can dig up a tutorial that stuff is over my head.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Interpolate: self.Rotation to [target rotation] duration: [target duration]
Timer: After [target duration] run to completion
-----[fire projectile]
How do I take an x,y coordinate and change it to the target rotation amount? In my minds eye it involves finding the angle from the center of my object and the touched coordinate and rotating to that angle, but I'm unsure of the math.
I'm looking at the joystick demo, as that uses similar math, but I haven't nailed it down yet
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Not sure if this'll work, but I have 'tracker' enemies in my retro shooter.
What they do is, every .25 they rotate to position of game.playerX and game.playerY
They're set to fire every .75 seconds.
Would that help at all?
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Using interpolate, i can set it to rotate to position over .5 seconds, but that .5 seconds is going to be the same for a 10 degree or 180 degree turn. but I could set the fire rate easily, and that's the path I'm looking at.
if I use the rotate function, I can have the rotation keep the same speed, so a 10 degree rotation is faster than a 180 degree rotation, but figuring out how to get it to fire upon stop is stumping me
I'm still playing around with the mechanics, it's not my strong suit, and it doesn't seem that complicated in my head, but getting it into GS is harder than I thought.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
myAngle = vectorToAngle(TouchX - turretX,TouchY - turretY)
What I ended up doing, and this seems to work, is when you click, I set an attribute to 1, and rotate to the position. When the angular velocity is 0, and fire is 1, I spawn the bullet, and set fire back to 0.
This seems to let me keep the static rotation speed, fires as soon as it stops, and I can do rapid fire as well.
again, thanks for the help, I never would have thought of this if I didn't keep trying new things.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io