Projectile not hitting player

I have an issue like in this previous thread were my projectile is going the opposite direction and not hitting the player.

in this thread problem was solved by turning isKinematic off I believe, but in my case I have had this turned already from previous steps when Ben hinted on us to do that.

My rotation on projectile is all (0, 0, 0)

Screenshot_7

Screenshot_4

my code for spawn projectile is as follows (cross checked with video, and I do not see any differences)

 void SpawnProjectile()
    {
        GameObject newProjectile = Instantiate(projectileToUse, projectileSocket.transform.position, Quaternion.identity);
        Projectile projectileComponent = newProjectile.GetComponent<Projectile>();
        projectileComponent.SetDamage(damagePerShot);

        Vector3 unitVectorToPlayer = (player.transform.position - projectileToUse.transform.position).normalized;
        float projectileSpeed = projectileComponent.projectileSpeed;
        newProjectile.GetComponent<Rigidbody>().velocity = unitVectorToPlayer * projectileSpeed;
    }

I cannot for the life of me pinpoint what causing this issue. As I have re-watched the lecture a couple of times now, and following every step to the sot while still getting this issue.

after re-watching the lecture a second time it was a typo on the line within the brackets

make sure its

(player.transform.position - projectileSocket.transform.position).normalized

projectileSocket.transform.position and not projectileToUse.transform.position

changed that line and everything works as in the video for anyone who might find themselves in the same situation.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms