I am building a game where i'd like the user to be able to drag back from the MainCharacter and fire a bullet in the opposite direction, like the angry birds slingshot firing system.
I can find plenty of examples using physics but none using the Bullet Behaviour.
What's wrong with using physics? That's the approach I would take, why a bullet behaviour? This is possible with the bullet behaviour, but I would like to know why the approach before I help if that's no problem.
Develop games in your browser. Powerful, performant & highly capable.
Use this principle;
Give your bullet the following behaviors;
a) Drag & Drop
c) Bullet (initial speed of 0)
1) Pin the bullet to the character using rope-style.
Combined with the Drag&Drop behavior, you will be able to move the bullet around like in angry birds by dragging.
2) On Drag&Drop (when the player drops the bullet);
a) Unpin the bullet
b) Disable Drag&Drop
c) Set bullet speed to a value (can be based on distance to character)
d) Set bullet angle of motion (based on angle to character)
The sling part of the system is just a visual trick. It doesn't actually serve any mechanical function.
David How do we calculate the Angle exactly? I realise the sling is just aesthetic and I can get my character to fire a bullet i'm just having trouble getting the bullet to fire from the character but at the right angle. Thanks for the reply!
dcrew the game is on a mobile platform and avoiding physics if possible is always best.