programmazione

Unity – Build – Flash Player

Unity – Build – Flash Player

0. MAIN TOP MENU> File> Buil Settings> Select Flash

1. MAIN TOP MENU> File> Buil Settings> ‘Player Settings’> Inspector to setup

2. MAIN TOP MENU> File> Buil Settings> ‘Build’> Scenes in Build> DRAG AND DROP the _Scenes> YourScene

3. 2. MAIN TOP MENU> File> Buil Settings> ‘Build’> Create Folder ‘Builds/space_shooter’> Save

WARNING: Development Build it is not compressed!

Errors

‘Error building Player: Exception: Could not start java’ you need to install 32-bit JRE:

1. Download: http://www.oracle.com/technetwork/java/javase/downloads/java-se-jre-7-download-432155.html

2. For Win7 64bit is: jre-7-windows-i586.exe (it is 32 bit jre because Unity is 32 bit!)

3. Run the installer as Administrator

By |Unity3D, Video Games Development|Commenti disabilitati su Unity – Build – Flash Player

Unity 3D – Pathfinding – NavMesh Obstacles

Unity 3D – Pathfinding – NavMesh Obstacles

These items are not baked into the NavMesh, and thus can move around freely while getting in the way.
Questi ostacoli non possono essere attraversati dal’agente, non sono calcolati nel NavMesh e si possono muovere liberamente nella scena.

1. Create a NavMesh
2. Create a ‘targetNavigation’ object
3. Create a NavMeshAgent

4. Create a game object and name it ‘moving obstacle’

Select ‘moving obstacle’ Inspector> ‘Add component’> Navigation> Nav Mesh Obstacle setup

– Radius: radius of the obstacle collider
– Height: height of ther obstacle collider
– Move Threshold (soglia):
– Carve (intagliare):

By |Unity3D, Video Games Development|Commenti disabilitati su Unity 3D – Pathfinding – NavMesh Obstacles

Unity 3D Game Engine – Pathfinding – NavMesh Agent

Unity 3D Game Engine – Pathfinding – NavMesh Agent

1. Create a NavMesh

2. Create EmptyObject, name it ‘targetNavigation’

3. Create a Sphere, Inspector> TOP RIGHT uncheck ‘Static’, name it ‘enemy’> Inspector> ‘Add Component’> Navigation> NavMeshAgent, setup:

– Radius: l’ingombro dell’agente

– Speed: massima velocità dell’agente (utile per i giochi di corsa!)

– Acceleration: accelerazione massima dell’agente

– Angular Speed: velocità con la quale è in grado di girare

– Stopping Distance: distanza alla quale inizia a rallentare in prossimità di ‘targetNavigation’

– Auto Traverse Off Mesh Link:

– Auto Braking: se attivo l’agente si ferma automaticamento al raggiungimento di ‘targetNavigation’

– Auto Repath: se attivo l’agente ricalcola il percorso se quello precedente non è più valido

– Height: l’altezza dell’agente

– Base Offset: offset verticale del collider dell’agente

– Obstacle Aviodance Type: High Quality – Low Quality – precisione del calcolo per schivare gli ostacoli (meno è accurato, meno risorse occupa)

– Avoidance Priority: priorità nella navigazione, un personaggio con priorità 1 avrà la precedenza (passa prima) rispetto un personaggio con priorità 2

– NavMesh Walkable: quale ‘Navigation Layer’ può attraversare

4. Select the Sphere and assign:

SimpleAgentScript.js


#pragma strict


    public var target : Transform; // inside Inspector assign the Target object
	private var agent: NavMeshAgent;
	
	function Start () {
		agent = GetComponent.<NavMeshAgent>();
	}
	function Update () {

				agent.SetDestination(target.position);
					
	}

Inspector> DRAG AND DROP over variable Target the ‘targetNavigation’ object

By |Unity3D, Video Games Development|Commenti disabilitati su Unity 3D Game Engine – Pathfinding – NavMesh Agent

Unity 3D Game Engine – Stealth Game – Single Doors – JS

Unity 3D Game Engine – Stealth Game – Single Doors – JS

Load prefab:
-> (parent) ‘door_generic_slide’
|Animator – Closed animation, Open animation inside are inside fbx file
|SingleDoorAnimator – uncheck Apply Root Motion – parameter bool: open – transitions: open->close close->open
|Sphere Collider – check ‘Is Trigger’ (to check player position)
|Audio Source Component (doorSwishClip + accessDeniedClip), uncheck ‘Play on Awake’
|DoorAnimation.js

–> (child) ‘door_generic_slide_panel’
|Mesh Renderer, check ‘Use Light Probes’
|Box Collider (to block the player penetration)
|Rigid Body, uncheck ‘Use Gravity’, check ‘Is Kinematic’ (to block the player penetration)

DoorAnimation.js:


#pragma strict

public var requireKey : boolean;                    // Whether or not a key is required.
public var doorSwishClip : AudioClip;               // Clip to play when the doors open or close.
public var accessDeniedClip : AudioClip;            // Clip to play when the player doesn't have the key for the door.


private var anim : Animator;                        // Reference to the animator component.
private var hash : HashIDs;                         // Reference to the HashIDs script.
private var player : GameObject;                    // Reference to the player GameObject.
private var playerInventory : PlayerInventory;      // Reference to the PlayerInventory script.
private var count : int;                            // The number of colliders present that should open the doors.


function Awake ()
{
    // Setting up the references.
    anim = GetComponent(Animator);
    hash = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent(HashIDs);
    player = GameObject.FindGameObjectWithTag(Tags.player);
    playerInventory = player.GetComponent(PlayerInventory);
}


function OnTriggerEnter (other : Collider)
{
    // If the triggering gameobject is the player...
    if(other.gameObject == player)
    {
        // ... if this door requires a key...
        if(requireKey)
        {
            // ... if the player has the key...
            if(playerInventory.hasKey)
                // ... increase the count of triggering objects.
                count++;
            else
            {
                // If the player doesn't have the key play the access denied audio clip.
                audio.clip = accessDeniedClip;
                audio.Play();
            }
        }
        else
            // If the door doesn't require a key, increase the count of triggering objects.
            count++;
    }
    // If the triggering gameobject is an enemy...
    else if(other.gameObject.tag == Tags.enemy)
    {
        // ... if the triggering collider is a capsule collider...
        if(typeof(other) == CapsuleCollider)
            // ... increase the count of triggering objects.
            count++;
    }
}


function OnTriggerExit (other : Collider)
{
    // If the leaving gameobject is the player or an enemy and the collider is a capsule collider...
    if(other.gameObject == player || (other.gameObject.tag == Tags.enemy && typeof(other) == CapsuleCollider))
        // decrease the count of triggering objects.
        count = Mathf.Max(0, count-1);
}


function Update ()
{
    // Set the open parameter.
    anim.SetBool(hash.openBool,count > 0);
    
    // If the door is opening or closing...
    if(anim.IsInTransition(0) && !audio.isPlaying)
    {
        // ... play the door swish audio clip.
        audio.clip = doorSwishClip;
        audio.Play();
    }
}

Inspector> DRAG AND DROP> variables:
– Door Swish Clip (Audio Clip)
– Access Denied Clip (Audio Clip)
– uncheck ‘Require Key’, you will open this door without a key

By |Unity3D, Video Games Development|Commenti disabilitati su Unity 3D Game Engine – Stealth Game – Single Doors – JS

Unity 3D – Stealth Game – HashIDs

Unity 3D – Stealth Game – HashIDs

Here we store the hash tags for various strings used in our animators.

1. Hierarchy> ‘gameController’


#pragma strict

// Here we store the hash tags for various strings used in our animators.
public var dyingState : int;
public var locomotionState : int;
public var shoutState : int;
public var deadBool : int;
public var speedFloat : int;
public var sneakingBool : int;
public var shoutingBool : int;
public var playerInSightBool : int;
public var shotFloat : int;
public var aimWeightFloat : int;
public var angularSpeedFloat : int;
public var openBool : int;


function Awake ()
{
    dyingState = Animator.StringToHash("Base Layer.Dying");
    locomotionState = Animator.StringToHash("Base Layer.Locomotion");
    shoutState = Animator.StringToHash("Shouting.Shout");
    deadBool = Animator.StringToHash("Dead");
    speedFloat = Animator.StringToHash("Speed");
    sneakingBool = Animator.StringToHash("Sneaking");
    shoutingBool = Animator.StringToHash("Shouting");
    playerInSightBool = Animator.StringToHash("PlayerInSight");
    shotFloat = Animator.StringToHash("Shot");
    aimWeightFloat = Animator.StringToHash("AimWeight");
    angularSpeedFloat = Animator.StringToHash("AngularSpeed");
    openBool = Animator.StringToHash("Open");
}

By |Unity3D, Video Games Development|Commenti disabilitati su Unity 3D – Stealth Game – HashIDs