- Home /
vector 3 isnt working offset part,the vector 3 isnt working 'offset' has a problem
using UnityEngine;
public class Followplayer : MonoBehaviour {
public Transform player;
public Vector3 offset;
// Update is called once per frame
void Update () {
transform.position = player.position;
}
}
,using UnityEngine;
public class Followplayer : MonoBehaviour {
public Transform player;
public Vector3 offset;
// Update is called once per frame
void Update () {
transform.position = player.position;
}
}
You're not doing anything in code with offset other than declaring it, so it won't actually have an effect on your player transform.
I don't know why you guys post questions with 2x titles and 2x text, but you're not even adding the offset here. Try this:
void Update () {
transform.position = player.position + this.offset;
}
Answer by Vicarian · May 15, 2018 at 04:36 PM
That's likely because the camera's position gets centered within the character's head. Adjust the position of the camera after parenting it along the Z axis to move it behind. And if the head can rotate independently, you'll want to make sure to parent the camera to a bone on the player that can't move.
Answer by Thewizard123456 · May 15, 2018 at 04:27 PM
@Thewizard123456 hi i really need help on this
Vicarian i am using offset for moving my cam away from player
Is the camera supposed to stay a specific distance away from the player or continually move away from the player? If it's fixed in space behind the player, parent the camera to the player and adjust its transform till you get something you like. You don't have to use code for it.
its meant to stay a specific amount behind the player but by parenting u go into fist person view
Please mark the comment I converted to an answer as the solution to close this thread.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
show spider on HoloLens emulator 0 Answers
Distribute terrain in zones 3 Answers
Errors Everywhere when updating unity 1 Answer
InvokeRepeating time doesn't sync within the same update function 2 Answers