Does anyone have any tips on how i can make a forward snap to a enemy and be able to have a adjustable offset from them?
public Transform Target;
public new Camera camera;
public float distance;
private void activateFinisher()
{
RaycastHit hit;
if (Input.GetKeyDown(KeyCode.F))
{
if (Physics.Raycast(camera.transform.position, camera.transform.forward, out hit, distance))
{
Debug.Log("hit");
if (hit.transform.CompareTag("Enemy"))
{
transform.LookAt(Target);
}
}
}
When I say the word offset, I mean a distance away from the enemy. The reason why I want an adjustable distance away from the enemy is so that it does not just go right Infront of the enemy's face. Instead allowing me to be able to implement a fisher animation.
CodePudding user response:
Player.position = Enemy.position Enemy.forward * offset;
should work