My character will walk up to you according to his torso because that is the middle point of the object. But I want him to walk up to you according to the knife in his hand so he can do the stab animation I made. Can Someone tell me how to make my character walk up in stabbing position.
Here is my script…
function FindClosestEnemy()
{
var waypoints: GameObject[] = GameObject.FindGameObjectsWithTag("Enemy");
var closestDist = Mathf.Infinity;
for (waypoint in waypoints) {
var dist = (transform.position - waypoint.transform.position).sqrMagnitude;
if (dist < closestDist) {
closestDist = dist;
closest = waypoint;
}
}
var DistanceBetweenClosestObject = Vector3.Distance(closest.transform.position, transform.position);
if(DistanceBetweenClosestObject >= 1.5)
{
FollowClosestEnemy();
}
}
function FollowClosestEnemy()
{
var lookPos = closest.transform.position - transform.position;
lookPos.y = 0;
var rotation = Quaternion.LookRotation(lookPos);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Damping);
var Forward = Vector3.forward * .05;
transform.Translate(Forward, Space.Self);
}
My functions are being called with other functions. This is only part of the script so don’t worry about that. Thanks in advance!!!
All of the variables are also being declared but I forgot those. Don't worry about that either...
– Gooey-ManI have no clue what your problem description is getting at. How does one "walk up to you according to the knife in his hand"? The cookie cutter tut code you included doesn't seem to be related at all. "Can Someone tell me how to make my character walk up in stabbing position." - are you asking how to make a crouch animation?
– getyour411