# Aiming an Object to throw it!

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?

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:

Here’s a sweet screenshot:

11 Likes

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

10 Likes

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

4 Likes

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.

2 Likes

Twisty Arrow is by @XAMANION

2 Likes

welcome to the forum!!

1 Like

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?)

3 Likes

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

4 Likes

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!

1 Like

Welcome to the forum! Did you add gravity?

2 Likes

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

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

1 Like

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!

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

1 Like

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

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

1 Like

Thank you for your input it helped my projects greatly. I appreciate your help with coding. I am just getting back into coding and although I understand math very well it was challenging to learn how to nest everything properly in the editor. I like your joystick design and it has helped my students. I wish there was multi touch functionality as I would like to have a joystick and fire button work at the same time but it does not seem to work well and one action will stop the other. Thanks again and happy coding!

Eric

4 Likes

This topic was automatically opened after 9 hours.