I am struggling with this for days now. Basically I am trying to make aiming system where player will tap and hold anywhere on the screen, and that guideline from player’s gun will appear to show where the bullet will travel if shot. I tried using this tutorial (Add Aim Feature in GDevelop 5 - Physics Engine Tutorial - YouTube) but there is two issues with it. The length of guide line can’t be changed (or I don’t know how), and it’s just awful because it is spamming those white dots every single frame by creating them constantly which is big performance issue.
EDIT: General idea how I want to make this to look like
You should try the Bézier curve of the shape painter object, but don’t ask me how to use it.
Will you be using physics to fire the bullet? Or can you do it ‘manually’?
The reason I’m asking is that I have a function that gets the position of a point anywhere along a bezier curve which is good for a manual bullet movement. If you combine this with a tween, you can place the guiding dots fairly evenly along the curve.
Let me know if this is something you’d lie to use, and I’ll see about knocking up an example.
Going with @gruk’s suggestion, something like this:
Here’s the event:
Hi, thanks for replying. Yes, I am using physics for the missiles because I need physics functions that comes with it. Anyway, I just tried this method it it “almost” works for me. I tried adding minus (“-”) in the Y control point, in front of everything, and that did fixed the flipping issue but was inaccurate too.
Anyways, here’s the video what I mean and my events.
That 400 and distance functions are just some numbers I put in to create a decent curve. Play round with them to get the curve a better fit - make the 400 smaller to flatten the curve, or bigger to increase the ‘hump’ of the curve. And you can try multiplying the distance function to affect the curve’s height. I’d look at starting with multiplying by 1.25 and seeing how that impacts it and then working with slightly larger numbers.
Ooh, I did that and managed to make it work now. One issue still left tho, I still can’t find a way of reducing this guideline so that the player can’t use it across the whole map. For example I want it to be maximum of 400 pixels in length. Is it even possible to do it? Any advice or idea is welcomed.
Add a condition when you draw the guideline that the distance from tank to crosshairs is less than 400.
Or only move the crosshair if the distance is less than 400.
I’ll just deal with the fact that this isn’t possible to do in this engine, and not to mention to customize the line so I’ll just remove this feature from my game.
There are numerous angry bird (and direct aim) style guidelines in games and demos made with Gdevelop, unfortunately people haven’t shared their math or events
I’d recommend you keep tinkering if you want it since it is definitely possible in the engine. I’m sorry that we cannot provide a direct solution, though.
Personally, I’d probably use a condition in the event that only has it be true if the mouse xposition is within whatever distance you want of the start position.
Edit: MrMens recommendation matches this as well, and should only require a single condition
You are right. I just found out this website Trajectory Calculator - Projectile Motion with instructions how to calculate trajectory of a missile, the only issue is that I don’t really know how to implement this in gdevelop but ig I’ll keep trying different methods untill I get it. Meanwhile, if anyone have any ideas about this, I am more then happy to hear it.
I remember seeing an example of something like this. Check this link:
The code is downloadable from there.
That’s the same as the tutorial OP linked in the first post. What @GasmoN is after is a bit more involved. I’m having a go at it, but the parameter equations are being a bit elusive.
I have also tinkered around with the Aiming sample. I love the idea and would use the mechanic in a game but it needs work and no work around I have found does it right.
Not sure if this will help but there is a page 9n stack exchange which is a bit more code like than the trig calculator