The arc is created, but if I'm in a dungeon it is much wider arc than when I'm outside. The arc length gets much smaller outside. Is there a difference in dungeon and world units that would effect how tight or wide the vector3 arc is?
Code: Select all
float currentWeaponReach = weaponReach;
//create forward cast that covers distance of weapon.
Vector3 attackcast = GameManager.Instance.PlayerEntityBehaviour.transform.forward * weaponReach;
Quaternion objectRotation;
//run the cast through lookrotation to ensure cast always is rotated to camera forward position.
objectRotation = Quaternion.LookRotation(attackcast);
//start lerp calculator that moves cast over a vector3 distance. This creates a half circle arc from right to left.
attackcast = Vector3.Lerp(new Vector3(-90f, GameManager.Instance.MainCamera.transform.rotation.z, GameManager.Instance.MainCamera.transform.position.z), new Vector3(110f, GameManager.Instance.MainCamera.transform.rotation.z, GameManager.Instance.MainCamera.transform.position.z), percentagetime);
//rotate calculated raycast so it is shooting in front of player no matter where the player looks/moves and how far into the arc cast we are.
attackcast = objectRotation * attackcast;