Thursday, 19 October 2017

Unity 2D Player Character Controller ( Finite state machine ) [02]



Unity 2D Player Character Controller (Creating Animations From Sprites) .

In This Tutorial We will Setup 2D character from scratch we will
(1) Create Animations From Sprites.
(2)Finite state machine setup.
(3)study parameter in FSM.
(4)scripting FSM changing Animations.
(5)scripting basic character movements (run,jump etc.)

Unity 2D Player Character Controller (Creating Animations From Sprites) ...




Unity 2D Player Character Controller (Creating Animations From Sprites) .

In This Tutorial We will Setup 2D character from scratch we will
(1) Create Animations From Sprites.
(2)Finite state machine setup.
(3)study parameter in FSM.
(4)scripting FSM changing Animations.
(5)scripting basic character movements (run,jump etc.)

Wednesday, 18 October 2017

Unity Change Material,shader And Texture at Runtime (Hindi /Urdu)






#Unity #shader #color #material #albedo #3d #2d
Change Obeject material and color at runtime also you can change shader.

https://docs.unity3d.com/ScriptReference/Material-ctor.html

Monday, 16 October 2017

Unity 2D Infinite Background Scrolling [ Simple Way ]






Visit youTube channel for more Awesome videos..

https://www.youtube.com/channel/UCOGA5JnlIF7spbyEDAkFG-g



download code here..

http://urdutechtutorials.blogspot.com/2017/10/unity-2d-infinite-background-scrolling.html

Unity 2D Infinite Background Scrolling Simplest Way

Watch Video Tutorial
Code for Infinite Background Scrolling IN Unity 2d game.

using UnityEngine;
using System.Collections;
 
public class Scroll : MonoBehaviour
{
 
    public float backGroundSize;
 
    private Transform cameraTransform;
    public Transform[] layers;
 
    private float viewZone = 0;
    private int leftIndex;
    private int rightIndex;
 
    private void Start()
    {
        cameraTransform = Camera.main.transform;   
 
        leftIndex = 0;
        rightIndex = layers.Length - 1;
    }
 
    void Update()
    {
        if (cameraTransform.position.< 
            (layers[leftIndex].transform.position.+ viewZone))
            ScrollLeft();
 
        if (cameraTransform.position.> 
            (layers[rightIndex].transform.position.- viewZone))
            ScrollRight();
    }
 
    private void ScrollLeft()
    {    
        layers[rightIndex].position = new 
           Vector3
           (1f * (layers[leftIndex].position.- backGroundSize), 0f0f);
        leftIndex = rightIndex;
        rightIndex--;
        if (rightIndex < 0)
            rightIndex = layers.Length - 1;
    }
    private void ScrollRight()
    {   
        layers[leftIndex].position = 
            new Vector3
            (1f * (layers[leftIndex].position.+ backGroundSize), 0f10f);
        rightIndex = leftIndex;
        leftIndex++;
        if (leftIndex == layers.Length)
            leftIndex = 0;
    }
}