(SOLVED) Hammer throwing enemy 🔨

I’m making an enemy (called Juuka) that supposed to throw hammers at you at an angle (Similar to hammer bro). I gave the hammer the platformer object behaviour in order to give it gravity (Because you can’t apply gravity as an action :man_facepalming:). I have it set to one specific angle, but I want it to be thrown at diffrent angles everytime he throws it.

I tried having it have a variable that change to a random number between 1 to 3 everytime the animation loops, and the angle it’s thrown is tied to the nmber of the variable. (Example: variable is 1 → throw at -45 degrees)

However the variable system did not work whatsoever, so I need to try something else.

These are my events for the enemy:

What should I do?

I think you’d be better off using physics behaviour, and applying a set force at whatever angle. Once the hammer collides with the ground or player, turn off the physics behaviour and treat it like an ordinary sprite object.

1 Like

or alternative if u don’t want physics go here SVG path creator - Plunker

create a curve like this

add curved movement behaviour to the axe
explore how curved behavior work
then
do trigger once—load curve (2,3 curves ecc…)

at the end of the curve applyu a force to make object fall

I tried doing mrmen’s suggestion, but the different angles still don’t work. I checked debugger, and it turns out when it does randominrange between 1 2 and 3, it does decimals between the numbers (Example: 2.5675445676). How can I get it so it just chooses between just 1 2 and 3 without decimals? (Rounding up)

1 Like

Hey!
In your events, you used RandomFloatInRange(1,3) which returns a random decimal. If you want rounded numbers, use RandomInRange(1,3)!
Hope this helps!
– Snowy

1 Like

Thank you! it did work.

1 Like