Aiming an Object to throw it!

help_me_please

#1

i Made a game that a character throws an object. Is there a way to aim the object so it follows a path instead of just straight such as throw it towards last touch x last touch y?

Your username:

What kind of device are you using?:

1 sentence description of the problem (I was doing _________, and then __________ happened):

Steps to make the problem happen:
1.
2.
….

I expected this to happen:

But instead this happened:

Here’s a sweet screenshot:


#2

Welcome to the forum!
I don’t know how to do that, but maybe @CodeHelp will!


#3

I know how, but in which aspect? Would you like it to go down as if there was gravity?


#4

Welcome to the forum!

I think @SmileyAlyssa made a game with physics like what you’re aiming for, check her profile out. The project is called Twisty Arrow if I’m correct. It has something to do with archery.


#5

Twisty Arrow is by @XAMANION


#6

welcome to the forum!!


#7

By following a path, do you mean having it be thrown up and have gravity pull it down (or thrown down and gravity pulling it up?)


#8

I am not sure how to code physics very well but there are some slingshot tutorials if that helps in any way!


#9

Yeah, I made an easy test of these physics, and this is what I came up with (yeah I now, it’s not that good).

Well, you can experiment with this so you can get get different arches depending on which angle you shoot it to, how hard, and so on. (This Project was just a TEST)

Btw Welcome to The Forum!


#10

Welcome to the forum! Did you add gravity?


#11

Welcome!
I’m not sure how but I’ll try my best to find a solution!


#12

Thanks everyone! So nice to get feedback. I already can do the slingshot thanks! I can throw an object in a straight line but was wondering how to throw it towards a direction like you see in other games like having a joystick to aim the direction and then fire projectile in the same direction as the joy stick. I can use sin and cosin of joystick I believe to set path but didn’t know how to make it move in the same path as my joystick. I found coding to be very fun to try and problem solve. Any help would be appreciated.

Eric


#13

No I want to be able to aim the projectile and fire it in that direction maybe with a joystick or last touch x last touch y on the ipad itself and have the projectile then fire from my character towards that spot. Thanks!


#14

Thank you so much. I had some of what you have worked out but I like your approach. I will play with it when I have time. I am new to the forum and I am glad to see that others also like to figure things out. I am teaching coding to third and fourth graders and I have to help them figure out what they want their games to do. Thanks for the help

Eric


#15

This one is a bit more complicated, but MUCH better! Check it out!


#16

So it sounds like you just want to aim and shoot at a specific point?

You said you’ve already calculated the angle and just need to make the projectile follow the path?

then the simplest method is to Set Angle of the projectile to the calculated angle, then Move Forward

Although the image of the projectile would have to be facing towards the right for that simple method to work