- Home /
Make Empty Follow an Object
i have an empty with 4 directions and i need make empty position follow the ball pivot in Axes X,Y,Z but no rotation
Code:
Vector3 vec_shooting_bola = new Vector3(ball.rigidbody.velocity.x, ball.rigidbody.velocity.y, ball.rigidbody.velocity.z);
empty_shootingBall.position = ball.position;
image:
i am making the empty with directions follow the ball in real time the ball have physics of an real ball but when the ball moves then the empty follow ball with smooth and get sliding til the ball stop......
Answer by CScherer549 · Jul 22, 2014 at 06:20 PM
I take it your solution isn't working? Have you tried parenting the empty to the object?
http://docs.unity3d.com/Manual/class-Transform.html
You should be able to use that and set it's rotation to 0 through a script. If that's not what you need let me know.
Answer by MarceloCosta_GamesBR · Jul 23, 2014 at 07:43 AM
Problem Solved
Instead of taking the position of the transform of the ball I took the position of the bone of the ball, it armature then following this perfectly now
Answer by ironblock · Jul 23, 2014 at 10:07 AM
this should do the trick.
Vector3 offset = new Vector3 (0,2f,0);
float step = walkSpeed * Time.deltaTime;
transform.position = Vector3.MoveTowards(transform.position, target.transform.position+ offset, step);
Your answer
![](https://koobas.hobune.stream/wayback/20220613154720im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
car follow ai 1 Answer
Follow only on Z axis? 1 Answer
Follow x rotation of a target object. 1 Answer
Enemy Pirate Ship AI 1 Answer