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