Skip to main content

Posts

Showing posts with the label Unity Animations

Use of Raycast to determine certain game objects ?

Raycast can be use in many fire like : There are many raycast type but these two are most that i used. 1.Physics.Raycast               Player shooting/Fire 2.Physics.SphereCast         Detect A object to Apply force due to explosion effect. Simple Physics Raycast as shown below :    RaycastHit hit;   Ray ray;    void Update ()     {         if ( Input .GetMouseButton(0))         {             ray = Camera .main.ScreenPointToRay( Input. mousePosition);               if ( Physics .Raycast(ray, out hit))             {                 Debug .Log( "Ray cast hit too " + hit.collider.gameObject.name);             }         }  }

Difference between an Animator and an Animation?

Animations are older versions of Animators . Animators where introduced in 3.0 to help overcome some short-coming that Animations have. Animations only change the visual representation of an object. This is fine if you're just changing opacity, but it causes issues when you translate, rotate, or scale objects. In the old days before Animators , if you translated the object, you had to perform a re-layout with the new coordinates. It could be rather difficult depending on where the object moved. Animators on the other hand change the physical properties of the objects. This means that if you move a View to a new location, the touch coordinates will be mapped at the new location without any other intervention. An Animation object animate the view's image. If you use this for example, to move a button around the screen you will not be able to click on it at the new visible position because it was not truly moved, but only his bitmap representation was translated. You will al...