how to have a GameObject orbit around the player with the camera?
so i'm making the beginnings of a third person shooter, and i'd like to have the gun orbit around the player along with the camera. i'm using cinemachine freelook. i've used some code i found online but it has the gun in some random place nowhere near the player. does anyone know how to fix this? i'm using raycasts to detect what the gun shoots. this is the script I am using.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CameraFollow : MonoBehaviour {
//
[SerializeField] public Transform cameraTransform;
//distance from camera public float distanceFromCamera; void Update() { Vector3 resultingPosition = cameraTransform.position + cameraTransform.forward * distanceFromCamera; transform.position = new Vector3(resultingPosition.x, resultingPosition.y, resultingPosition.z);
}
}