child relative to camera position

didn’t know what other forum to ask so I am putting this here:

I have a game object that has a laser shoot out of its position to where I am looking with the camera in a fps game. As it is a child of the player it moves with the player, but the player itself doesn’t rotate with the camera, only the camera looks around. the shoot point is bottom right if I don’t look around, but if I turn around its bottom left.

pretty please help me rotate the shooting point with the camera bc I dont know how

without having turned:


turned around:


If you’re not asking a physics question then the physics forum isn’t appropriate. Asking a generic scripting question is best asked on the Scripting forum so I’ll move your post there for you. :slight_smile:

You have a quirky setup but drop the script below onto your AttackPoint object.

using UnityEngine;

public class CamOffset : MonoBehaviour
{
   Vector3 offset;
   void Start()
   {
      offset=transform.position-transform.parent.position;
   }

   void Update()
   {
      transform.position=transform.parent.position+Camera.main.transform.rotation*offset;
      transform.rotation=Camera.main.transform.rotation;
   }  
}

thank you

This is perfect, thank you so much