Cannon Explosion Effects Won't Sync with it's tip (rotation constraint problem)
Hey all! Quick question. I've got a cannon that rotates (like the hands of a clock). When I fire the cannon I want the explosion effect (actor) to be constrained to the tip of the cannon. I've got an attribute that registers the cannon's Launch Angle in case that helps.
Thanks so much!
Thanks so much!
Comments
I couldn't find the exact answer to my questions, but the part where he goes over sin and cos is what helped me get my weapons firing correctly.
REFERENCE:
My game has a cannon. Rotates around like a clock hand. I wanted an explosion effect to shoot out from the tip of the cannon.
So the I had a CANNON actor and a EXPLOSION actor.
First thing you want to do is gauge how many pixels the explosion actor is from the center point of the cannon to the tip point. In my case it was 180. So that's the number I'll be referencing here. Obviously please substitute in your own value. Also a heads up I have a REAL attribute called "CANNONangle." This attribute is a vectortoangle value of the cannon's direction via the users tap on screen (i.e. the cannon follows the angle of the user's finger on screen).
THE CODING:
When user fires cannon SPAWN ACTOR-EXPLOSION
I set everything to SCENE (relative to:)
Direction: 0
Postion X: 180*cos(CANNONangle%360)+self position x
Position Y: 180*sin(CANNONangle%360)+self position y
The self position x and y are in reference to the Cannon's object self position
Hope this helps!