Page 1 of 1

Difference in Dungeon vs World Units?

Posted: Wed Jun 22, 2022 2:47 am
by l3lessed
I'm getting an interesting result when casting raycasts over a arc using a basic lerp function.

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;

Re: Difference in Dungeon vs World Units?

Posted: Wed Jun 22, 2022 4:41 am
by BadLuckBurt
There is no difference in units, there are only Unity units where 1 unit == 1 meter.

If it's the same code being fed the same values, the results should be the same so maybe try some hard-coded experiments?