Hi,
So i’m building a game (not this APK) with moving tanks that are shooting on each other. It’s almost ready but there is just only one thing i can’t fix. I want the green ball to stick at the red piece well the brown/red stick is rotating. Does someone know the right formula? I’m not that great at math. I have searched on google and the only thing is that it’s has something to do with polar cordinates, but i’m not really sure.
I hope there is someone that can help me.
Thanks,
I hope he can help me.
ball1.x to stick1.center.x - (stick1.width * cos(stick1.heading))-ball.radius
ball1.y to stick1.center.y - stick1.width * sin(stick.heading) - ball1.radius
Where is the center block? Or do you mean the middle of the sprite width?
I didt it like this, but it doesn’t work i’m afraid
I think i did not set the blocks in the right order.
If you set the Z of the cannon higher than the z of the ball, the cannon will cover the ball.
Then you can set the ball at the center of the rotating cannon and when the player shoots, give the ball the same heading the cannon has. When you set the speed, the ball will look like it’s coming from inside the cannon. Is that what you want?
What happened? What “doesn’t work” means?
well the ball is staying at the right bottom well i rotate the stick.
It’s not moving at all.
didt i place the blocks at the right way?
That’s how i have it now, but when the player shoots i want to have it look like there is some fire or smoke comes from the cannon. So i want to place a image sprite with smoke and fire right in front of the cannon. Also when i do it on this way there is a little delay when the ball comes from the cannon.
Just like this.
That’s how it is in real life, the bullet doesn’t come out of the tip of the cannon. If there’s a delay, then probably you need to make the ball faster.
About the fire, I would make a sprite just like the cannon, but bigger. It would be transparent except for the part where you want to draw the fire. Set it to invisible and always give it the same heading the cannon has.
When the user shoots, make it visible for, let’s say half second, or any time you think looks better, then make it invisible again.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.