Be the first to post for 'Using The Trail Renderer Component'!

If you’re reading this, there probably aren’t very many posts yet. But don’t worry, you can be the first! Either create a new post or just reply to this one to say ‘hi’.

Hello Again

During this video I tired to replace the Fast Projectile object with an Arrow I downloaded from the asset store. After I added the required components to the Arrow Object and put it on the arrow it began behaving funny. When I drop the arrow prefab into the scene the object is horizontal like I want it to be but during play (as you can see in the video) the rotation changes.

DropBox link if video doesnt work: https://www.dropbox.com/s/evblici68i1s9sp/ArrowIssue.mp4?dl=0

…Had no issues getting the Fast Projectile working with the trail renderer.

This may be a bit late for Crede.Pendrel, but I had a similar issue so maybe this will save someone some time.
The orientation of the arrow with respect to its transform is going to depend on the mesh as exported from the design tool. You need to orient the transform so that the arrow is pointed in the direction of the target (player). Here is my code in Enemy.cs in case it is helpful.

private void SpawnProjectile() {
    Projectile newProjectile = Instantiate(projectile, projectileSpawnPoint.transform.position, projectileSpawnPoint.transform.rotation).GetComponent<Projectile>();
    newProjectile.damageCaused = damagePerShot;
    Rigidbody rb = newProjectile.GetComponent<Rigidbody>();

    Vector3 playerDirection = (playerTransform.position + verticalAimOffset - projectileSpawnPoint.transform.position).normalized;
    rb.velocity = playerDirection * newProjectile.projectileSpeed;
    rb.angularVelocity = new Vector3(4f, 0, 0);
    rb.transform.transform.forward = playerDirection;
}

If you find the arrow is at 90 degrees to the point of travel, this can be corrected using Transform.Rotate().

My projectile
image

Privacy & Terms