Monday, 7 September 2015

How to use Enemy in Unity

Enemy Aim AI Unity


An Enemy is a person who is actively or hostile to someone or something.
Enemy aim AI is very useful when you want an enemy to aim towards the player controller.

Proper aiming towards an object takes time in real world scenario, so the enemy will take some amount of time before it locks on the target.

Quaternion stores the rotation of an object and also evaluates the orientation value.

One can directly play with Euler Angles, but there may arise situations of Gimbal Lock.

According to the local coordinate system, if you rotate a model about its X-axis then its Y and Z-axis experience a Gimbal lock and become “locked” together.

It Currently works fine for one enemy, but as soon as there are multiple enemies, the possible solution would be to make the enemies move in a random direction every few frames.

More this blog here: Enemy Aim AI Unity


Enemy Follow Script



We create a script similar to the hero’s movement controls script.

The only additions are the Accelerate and Invoke Repeating functions.

It will create a leaping effect while moving towards the targeted object.

It would look as if the enemy is thinking by itself and trying to catch the targeted object.

This kind of AI is a very useful case of action games, where the enemy follows a player and tries to shoot or attack.

One can change the challenge condition as per the need.

It can also increase the following speed in the script in a condition where it is mandatory that the followers should be able to catch the target object.

More this blog here: Enemy Follow Script


Enemy Obstacle Awareness AI




A Ray cast is used to delete if there is any object having collider within the given range and specified direction.

Ray cast is a static method which returns Boolean value i.e true if there is anything and false if there is nothing.

The front rays are used to detect the obstacles if obstacles are found the cube is rotated in either left or right direction to avoid the obstacle.

When front rays detect the obstacle, it should focus only on the obstacle for that point in time.

The backside rays are used to confirm that obstacle is avoided which front rays previously detected.

More this blog here: Enemy Obstacle Awareness AI





Wednesday, 2 September 2015

How it Works User Interface 4.6 in Unity


Working With Unity UI 4.6



Unity has been hard at work getting the new UI system ready for release in Unity 4.6.

The UI System allows you to create User Interface (UI) fast and intuitively.

This is an introduction to the major features of Unity’s new UI systems.

Unity 4.6 has a newly added feature UI in it. Using Unity UI we can manage our game
User Interface.

Using React Transform tool, we can manage scaling, position and rotation of UI
Element and Pivot tool manages pivot point of UI elements

The UI system in Unity includes a variety of tools for this purpose that can be in various ways.

UI 4.6 provides many built-in components to develop the user-friendly interface.

Read more this blog here: How it Works with Unity UI 4.6


Button Click Effect in UNITY 4.6 UI Using Scripting




In this unity 4.6 tutorial, we all take a look at the basics of using the new UI to create a “world space” text appear via a scripted trigger.

You can give click effect to a button through animation or scripting.

There are following variables in the inspector for Button Click script.
-    First is used to set a scale of a button at a start.
-    Second is used to set the scale or the button when it’s being clicked.



Dynamic Scroll View in Unity 4.6 UI 



This script, when attached to a panel turns it into a scroll view.

You can then attach Dynamic Scroll View to colliders within to make it dynamic.

The images to assign “Dynamic Scroll View” script to panel scroll view game object.

Drag and Drop all the other required objects to that script in the inspector.

A simple scrollbar is used here to scroll the content.

The game object named ‘item’  is used as the content of the scroll view.
Panel scrollbar game object contains Scroll-Rect and Scroll Content contains grid layout group component 

Read more this blog here: Dynamic Scroll View in Unity 4.6 UI