Skip to main content

Posts

Showing posts from February, 2021

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);             }         }  }

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);             }         }  }

Find Nearest Enemy/Object in Unity 3D

There will be many Situation where you have to find the nearest Enemy or nearest object from a player or a object. For this this below code is useful ;  void Update ()  {       Collider [] c = Physics .OverlapSphere(transform.position, 20);       Transform t = GetClosestEnemy(c);       print( "Nearest Object Name" + t.gameObject.name);   }   Transform GetClosestEnemy( Collider [] enemies)   {       Transform tMin = null ;       float minDist = Mathf .Infinity;       Vector3 currentPos = transform.position;       foreach ( Collider t in enemies)         {             float dist = Vector3 .Distance(t.transform.position, currentPos);             if (dist < minDist)             {                 tMin =...

Find the Distance Between Two Game Objects in Unity 3D

T ake a two Game Objects ObjA & Obj and write script as Follow : public Transform ObjA; public Transform ObjB; float FindDistanceBetweenObjects() {         float _dis = Vector3 .Distance(ObjA.position, ObjB.position);         return _dis;  }   void Update() {         float Distnace = FindDistanceBetweenObjects();         print("Distnace" + Distnace);   }

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...

Advantage to Know Before Choosing Unity 3D.

Unity 3D is one of the leading Game Engine now a days.But,before you  Begin with Unity here are the some advantage you know before you begin with the Unity.  Here is the list : 1. Cross platform,The games you make can be rendered to be used on over 25 platforms across mobile, console, desktop, TV, AR, VR and the Web. Imagine having all of that power in the palm of your hands. That’s how powerful and diverse it is. 2 .Unity is the best Engine for Game development. It is very effective while rendering 2D and 3D scenes.The quality offered is also relatively good compared to other Engine. 3. The assets store of unity is also great when compared to other platforms.The tech support for Unity is efficient.The tech support members are also highly skilled and they can be relied upon in case of any technical issues. 4. The Unity game engine is also easier to use compared to many other technologies. There are so many other complicated technologies which become tougher while we use. Unit...

Camera Shake in Unity 3D

Camera shake Normally used when a player get hit or you want to do something related to shaking. // Transform of the camera to shake. Grabs the gameObject's transform           public Transform camTransform; // How long the object should shake for. public float shakeDuration = 0f; // Amplitude of the shake. A larger value shakes the camera harder. public float shakeAmount = 0.7f; public float decreaseFactor = 1.0f; Vector3 originalPos; void Awake()           { if (camTransform == null ) { camTransform = GetComponent(typeof(Transform)) as Transform; } } void OnEnable() { originalPos = camTransform.localPosition; } void Update() { if (shakeDuration > 0) { camTransform.localPosition = originalPos + Random.insideUnitSphere *                                    shakeAmount;...

Recommended Assets For Your Unity Project.

1 .Toony Colors Pro 2 Toony Colors Pro 2 is a collection of stylized shaders and tools, with an emphasis on ease of use and flexibility. Making your Unity game stylized has never been so easy! Source code is fully included! Link To Asset :  Toony Color Pro 2 2 .Joystick Pack It is Free. The joystick pack contains multiple different virtual joysticks which can be easily used in your projects with a simple drag and drop. The pack also comes with 18 background and 6 handle sprites allowing for lots of customization or you can use your own. Link To Assets :  Joystick Pack 3 .iTween It is Free. More "wow" for a lot less "ow". iTween is a simple, powerful and easy to use animation system for Unity. Focusing on the established solutions and frameworks of projects such as TweenLite, Tweener, and other Flash-based tweening and interpolation systems, iTween is a battle-tested solution for streamlining production in the Unity environment. Link To Asset :  ITween 4 .LeanTween I...