Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

How do I make the camera follow a vector3? 3D

$
0
0
my player makes a raycast from the camera to the position of the mouse (the player looks at that hit) my intention is to calculate the midpoint between that hit and the player, and that the camera looks at that vector with a clamp so that it does not go to the infinite, the problem that is not happening locally to the player but the world, so if I move away from the center the camera stays behind and does not follow the player. it only works "well" when the player is in the center of the map Vector3 distance = _player.transform.position - _player.GetComponent().hitSave; Vector3 midpoint = new Vector3(-distance.x / 2, transform.position.y, -distance.z / 2); xLimit = Mathf.Clamp(midpoint.x, -4, 4); zLimit = Mathf.Clamp(midpoint.z, -4, 4); Vector3 follow = new Vector3(xLimit, transform.position.y, zLimit); //Vector3 followTwo = new Vector3(midpoint.x, transform.position.y, midpoint.z); transform.position = Vector3.Slerp(new Vector3(follow.x, transform.position.y, follow.z), follow, smooth); transform.eulerAngles = new Vector3(60, -90, 0);

Viewing all articles
Browse latest Browse all 536

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>