🔫Weapon

In this section you will learn how to implement FPSAnimWeapon

Step 1 - Add FPSAnimWeapon

Similarly to the character, your weapon class also needs to be derived from a special animation abstract class - FPSAnimWeapon.

YourWeapon.cs
public class YourWeapon : FPSAnimWeapon //<- inherit from FPSAnimWeapon
{
}

The only change you need to make is to override the GetAimPoint() method:

Weapon.cs
public override Transform GetAimPoint() //<- override this in your Weapon class
{
    _scopeIndex++;
    _scopeIndex = _scopeIndex > scopes.Count - 1 ? 0 : _scopeIndex;
    return scopes[_scopeIndex];
}    

In this code we iterate over all scope transforms when player changes a scope.

Last updated