Explain me The Following Code Snippet Below:
Class Mover : Monobehaviour
{
Vector3 Target;
Float Speed;
Void Update()
{
}
}
Finish This Code So The Gameobject Containing This Script Moves With Constant Speed Towards Target, And Stop Moving Once It Reaches 1.0, Or Less, Units Of Distance?
Submitted by: Muhammadclass Mover : MonoBehaviour
{
Vector3 target;
float speed;
void Update()
{
float distance = Vector3.Distance(target,transform.position);
// will only move while the distance is bigger than 1.0 units
if(distance > 1.0f)
{
Vector3 dir = target - transform.position;
dir.Normalize(); // normalization is obligatory
transform.position += dir * speed * Time.deltaTime; // using deltaTime and speed is obligatory
}
}
}
Submitted by: Muhammad
{
Vector3 target;
float speed;
void Update()
{
float distance = Vector3.Distance(target,transform.position);
// will only move while the distance is bigger than 1.0 units
if(distance > 1.0f)
{
Vector3 dir = target - transform.position;
dir.Normalize(); // normalization is obligatory
transform.position += dir * speed * Time.deltaTime; // using deltaTime and speed is obligatory
}
}
}
Submitted by: Muhammad
Read Online Unity 3D Developer Job Interview Questions And Answers
Top Unity 3D Developer Questions
☺ | Explain me what Is The Function Of Inspector In Unity 3d? |
☺ | Tell us what Is An Unity3d File And How Can You Open A Unity3d File? |
☺ | Tell us in Unity 3d How Can You Hide Gameobject? |
☺ | Explain me total Sessions Today? |
☺ | Do you know what Is Prefabs In Unity 3d? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |