Reputation: 1
I'm adding two Vector2's together and the result is simply the first Vector2 even though the second Vector2 has a value, its a small value but still a clear value which should be added to the first one. Does anyone know what could output this?
Code that has the debug logs and the addition of Vector2s:
public virtual WeaponState UpdateState()
{
Vector3 translate = new Vector2(Mouse.current.delta.x.ReadValue(), Mouse.current.delta.y.ReadValue()) * sensitivity;
if ((Vector2)translate == Vector2.zero)
return this;
Debug.Log("WeaponPos: " + weapon.transform.position);
Debug.Log("Translation: " + translate);
Vector2 newMousePos = new Vector2(weapon.transform.position.x + translate.x, weapon.transform.position.y + translate.y);
Debug.Log("WeaponPos + Translation: " + newMousePos + ". WeaponPos: " + weapon.transform.position);
Vector2 pivotPoint = weapon.GetPivot();
float distanceWhenTraveled = UtilityF.Distance2D(newMousePos, pivotPoint);
return Execute(pivotPoint, newMousePos, distanceWhenTraveled);
}
An example of an output:
WeaponPos: (-9.02, 2.41, 0.00)
Translation: (0.00, -0.01, 0.00)
WeaponPos + Translation: (-9.02, 2.41). WeaponPos: (-9.02, 2.41, 0.00)
Why is the result of "WeaponPos + Translation" not (-9.02, 2.40) here instead?
This is the place where the debug logs are written
This is the output of the debug logs captured
Upvotes: 0
Views: 228