Forum begins after the advertisement:
-
::Hello,
I just worked on the axe weapon from part 16 and I’m having difficulties with the weapon being thrown up. At the moment the weapon spawns in and falls in whichever way the player is facing. I did some searching and using ChatGPT, I got some logic that will throw the axe upward(not very smooth) but I currently have that commented out because I wanted to see if I missed something or I’m misunderstanding the physics.
Thank you
::Hi Nathan, can you share your code for the AxeWeapon
? If you’re able to get a video recording of the axe spawning, that will be great as well.
::Apologies, here you go.
<code>public class AxeWeapon : ProjectileWeapon
{
//gives the spawn angle when instantiated
protected override float GetSpawnAngle()
{
//calculates offset that is used to modify the angle of axes
int offset = currentAttackCount > 0 ? currentStats.number - currentAttackCount : 0;
//instantiates the first projectile at 90 degrees and modifies future axes during attack
return 90f - Mathf.Sign(movement.lastMovedVector.x) * (5 * offset);
}
protected override Vector2 GetSpawnOffset(float spawnAngle = 0)
{
return new Vector2(
Random.Range(currentStats.spawnVariance.xMin, currentStats.spawnVariance.xMax),
Random.Range(currentStats.spawnVariance.yMin, currentStats.spawnVariance.yMax));
}
}
</code>
View post on imgur.com
::What is the Speed attribute of your Axe in the WeaponData file? Try increasing it and see if this fixes the issue.
::Ah, that was it. It was set to 1. Increasing it fixed it.
Thank you
View post on imgur.com
Advertisement below: