Pull back and launch system

Hey, so I’m working on a mechanic for my game where you drag your mouse back and release and then the object shoots forward. Kinda like a bow and arrow.

Could anyone help me figure it out?

Thanks!

4 Likes

Similar to that of like an angry birds system?
I actually thought about testing out a system for that, but the closest thing I can see is maybe using a joystick example and someone converting or linking it to a projectile feature.
I actually would really like to see this done, but there’s no way I’d be able to figure out something like that.

3 Likes

Maybe @BitWit has some input - he just made an awesome golf game with a pull back & launch system.

There is also this: Flowlab Game Creator - Unfinished Heist - Physics Template but it’s not exactly what you wanted

5 Likes

Oh really? :sob: I was going to do a neon golf game!

Can I still do it, or will points be taken off for not being original?

2 Likes

I’m sure you can still use it if you credit him, or touch up the code to make it a little more unique so it can still be original.
Grazer said in the flowjam that you can use anything that you make, but if you use someone else’s work then you must credit them. So I’m assuming you probably won’t be docked points.

2 Likes

It’s not going to be exactly like his, I was planning on making around 50 levels of rotating wheels and other objects blocking the hole, and then having a shop to get better golf balls.

I don’t think I’ll use his code either.

2 Likes

Thanks for the help maniac and grazer.

I realized that the pull back mechanic is the most satisfying part.

So if anyone has any idea, it would be very appreciated!

2 Likes

What part(s) are you struggling with?

I think the general idea is use PointAt to face the mouse, and measure the distance between the mouse and the ball to find the impulse force to apply.

You can use an attachment to display the arrow, and scale it according to the force. Alternatively, you could spawn a row of indicator objects between the ball and the mouse pointer

2 Likes

I’m honestly just struggling with the whole thing :rofl:

I can’t figure out how to make it be able to drag from anywhere and shoot, or measure the distance and then transform that into velocity.

Also, does mouse move work on mobile?

1 Like

@JR_01 or @PixelPizza

Could you help create the mechanic?

1 Like

I think you should just approach it in small steps, one at a time. That way it will be easier to build and easier for people to help with. Here’s what you should do, one step at a time:

  1. make your ball point at the mouse position using PointAt

  2. measure the distance between the ball and the mouse. There is an example of this in the game I’m working on in the enemy Hunt bundle. I discuss how to get the distance between two objects here if you want to see it: Twitch

game is here: Flowlab Game Creator - New Game

  1. Use that distance to determine the impulse force to add to your ball when you release the mouse

  2. Add an arrow sprite as an attachment to your ball

  3. Scale the arrow sprite using the distance from step 2

5 Likes

Hey @Johnny_boy, my game basically uses two seperate ideas to achieve the system seen. Mine is just aiming (no pulling or launching), but that could easily be changed. If you want to borrow mechanics from my game that is totally fine. So here is how the mechanic works.

First, the ball is always rotating towards the mouse. This may seem inconsequential, but it’s actually vital for the system to work for reasons you’ll see in a second. Next, the ball measures the distance from itself to the mouse. Once the player clicks, the ball calculates the difference and does an operation to convert that number into the forward velocity then makes it opposite. By rotating the ball towards the mouse, the forward velocity will go towards the arrow, but by making it negative, it’ll always shoot away from the cursor.

If you want this to be adapted for tap and swipe, some small changes would need to made such as rotating towards the cursor once it detects click down, then calculating the mouse’s position and shooting on click up instead.

4 Likes

Hey thanks for the help guys.

I might have to back out of the jam unfortunately due to time shortness.

1 Like