A small update for throwing weapons

Hello every one.
If like me you want to create some throwing weapon like spears, coctail Molotov, stones etc… so directly the weapon you wear (not as the bow where you spawn the arrow) if you don’t add a condition in projectile script you will have an error message such this ones:

NullReferenceException: Object reference not set to an instance of an object
RPG.Combat.Projectile.GetAimLocation () (at Assets/Scripts/Combat/Projectile.cs:43)
RPG.Combat.Projectile.Start () (at Assets/Scripts/Combat/Projectile.cs:22)

The main error comes from the start line in projectiles script.
As soon as your weapon spawner spawn it wants to Look at a target:

void Start()

    {        

        transform.LookAt(GetAimLocation());//Dés le départ on vise la cible.Annule l'effet missile chercheur.

    }

For me it doesn’t block the game and my stones or molotof react normally but the spawner always want to look at something.

So I’ve fix the error by adding a condition in the Start method:

void Start()

    {
        if(target != null)
        {
            transform.LookAt(GetAimLocation());
        }
    }

Bye
François

1 Like

Hi I think it is in the wrong course section!

Ouppss.
Yes you’re right.
Fixed.
Thank you FedPete

1 Like

Privacy & Terms