Playmaker Help & Tips > Playmaker Help

Creating a spring-loaded launching mechanic in 3D, ala Angry Birds

(1/2) > >>

Hey guys,

Just trying to think through how I'm going to setup my Angry Birds-like slingshot mechanic, and I could use your help thinking through the FSM logic.

I have a character who's going to cast a fishing line. I want the player to cast the line by clicking on a spot in the water, dragging backwards, and when they let go, the line shoots out a projectile. The projectile flies at a velocity equivalent to the amount that was pulled back.

I'd like to limit the amount of pull-back that can happen. So for example, if a player clicks at the very top of the "lake" that is furthest back, the pullback amount will cap out at a certain distance.

I also need a way to conver the pull back strength into a velocity amount for a physical projectile.

Thanks in advance for your help :)

I have not tried to build something like that yet,
but there is an asset on the asset store which is build with playmaker called Slingshot Playmaker Kit but it seems to be for mobile.

In pseudo code, something like this in my mind.

Point A, the sling shot. Click and drag back with the mouse. This is point B.

Measure the distance between A and B. Keep checking it on everyframe. Do a float compare. If it is beyond your max distance, take action to not allow the rope to move farther.

Use distance between point A and B to determine velocity. (Add force). Ie, distance * 2 = force. (You will need to see how much force is best for you).

Use two points to determine heading. Normalize the heading to get direction. Apply force when the mouse button is up, in that direction.

Excellent advice!

djaydino - I have looked at Slingshot Kit, but it only offers a 2D solution.

tcmeric - How would I go about drawing the expected trajectory curve? It would need it to go out FURTHER from the "slingshot" as you click-drag your mouse CLOSER to the slingshot. I am struggling with the vector math for this.

I used this asset:!/content/55752

I talk about it on my youtube channel, around the 13 minute mark of this video:

I wrote a custom action to assist for it:

If you watch the video through, it will also show you how I got direction between game objects etc (custom action).


[0] Message Index

[#] Next page

Go to full version