transform.position assign attempt for 'RCCMainCamera' is not valid. Input position is { NaN, NaN, NaN }. UnityEngine.Transform:set_position(Vector3)
transform.position assign attempt for 'RCCMainCamera' is not valid. Input position is { NaN, NaN, NaN }. UnityEngine.Transform:set_position(Vector3)
transform.position= SmoothApproach(pastFollowerPosition, pastTargetPosition, targetPosition, Mathf.Clamp(0.1f, speed, Mathf.Infinity));
Answer by AtifatGamy · Jul 11, 2018 at 11:40 AM
It is Due to the "Divide By Zero " Situation that yields infinity or NaN position .. To Solve the issue I have used a check if my Time.deltaTime was not returning zero.. Here is How I have solved my issue by altering the SmoothApproach method a little bit in the RCCMainCamera Script...
You can replace The Method by following code or embed the check yourself to avoide the "Divide By Zero" situation in the code..
It is bcoz of Division by zero in SmoothApproach Method in the RCCMainCamera Script... you may resolve this by navigating to the method .. i have solved it bcoz it was occuring as my time.deltatime was returning 0 which was yielding to "Divide By Zero" situation and hence was resulted in NaN position... To solve it alter the code in SmoothApproach Method as given below...
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
private Vector3 SmoothApproach( Vector3 pastPosition, Vector3 pastTargetPosition, Vector3 targetPosition, float delta)
{
if(float.IsNaN(delta) || float.IsInfinity(delta) || pastPosition == Vector3.zero || pastTargetPosition == Vector3.zero || targetPosition == Vector3.zero)
return transform.position;
float t = Time.deltaTime * delta;
// Check if and only if time.deltaTime * delta was not returning zero as it was in my case
if (t > 0) {
Vector3 v = (targetPosition - pastTargetPosition) / t;
Vector3 f = pastPosition - pastTargetPosition + v;
return targetPosition - v + f * Mathf.Exp (-t); }
else
{
return transform.position;
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Your answer
Follow this Question
Related Questions
Camera isn't move position? Why my camera isn't change position? 0 Answers
Position of empty game objects 1 Answer
Raycast only occurs on start 2 Answers