- Home /
Buff Follow
Hello Unity3D.I have a question about making an object follow a player.How can i make it that i can make a object follow a character/player?For example.I have a buff for my character that it uses which is a sword and i want it that whenever my character moves the sword follows the character at the exact speed time.If anyone knows how i can do this.Can you please tell me how?I have been searching and i can't find it.
Script if anyone needs it
var target : Transform;
var moveSpeed = 100;
var rotationSpeed = 0;
var myTransform : Transform;
function Awake() {
myTransform = transform;
}
function Start() {
target = GameObject.FindWithTag("Player").transform;
}
function Update () {
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
What exactly do you mean by follow? Just behind, a long way behind, to the side? Follow in terms or rotation(orientation) or follow in terms of position or both etc???
Oh im sorry, I mean i want the sword to follow the character around him/her like a guarding type buff. I already made an animation in blender of the sword rotating in a circle i just want it to follow the character wherever it goes.
Answer by FairGamesProductions · Dec 11, 2014 at 11:24 PM
In that case, make the sword a child of the character and zero out it's LocalPosition.
Your answer
![](https://koobas.hobune.stream/wayback/20220613173831im_/https://answers.unity.com/themes/thub/images/avi.jpg)