2015年2月9日 星期一

difference between Update and FixedUpdate

 Update
update in the amount of Framerate

 FixedUpdate
update in the amount of 24fps

unity - showing instance object [System.Serializable]


[System.Serializable]

public class Boundary{
    public float minX,maxX,minZ,maxZ;
    }



public class PlayerControlor : MonoBehaviour {
    public Boundary boundary;



}

unity - rigidbody rotate






        rigidbody.velocity = movement*speed;


        rigidbody.rotation = Quaternion.Euler (0,0,-rigidbody.velocity.x *tilt);

unity - get keyboard arrow ,



        float moveX = Input.GetAxis ("Horizontal");
        float moveY = Input.GetAxis ("Vertical");



        Vector3 movement = new Vector3 (moveX0.0fmoveY);


        rigidbody.velocity = movement*speed;









unity - flight, plane control

[System.Serializable]

public class Boundary{
    public float minX,maxX,minZ,maxZ;
    }

public class PlayerControlor : MonoBehaviour {
    public Boundary boundary;
    public float speed=0.01f;
    public float tilt=4;

    void FixedUpdate(){
        float moveX = Input.GetAxis ("Horizontal");
        float moveY = Input.GetAxis ("Vertical");

        Vector3 movement = new Vector3 (moveX0.0fmoveY);
        rigidbody.velocity = movement*speed;
        rigidbody.rotation = Quaternion.Euler (0,0,-rigidbody.velocity.x *tilt);

        rigidbody.position = new Vector3 (
            Mathf.Clamp(rigidbody.position.x,boundary.minX,boundary.maxX),
            0.0f,
            Mathf.Clamp(rigidbody.position.z,boundary.minZ,boundary.maxZ)
                );
    }
}

2015年2月8日 星期日

unity 3d, texture material

3d model:
http://tf3dm.com/3d-models/unity

petergo
jy02927731@yahoo.com.hk
00423564


https://3dwarehouse.sketchup.com/?redirect=1
facebook




2015年2月6日 星期五

Unity - panel trigger

public class gameOverTrigger : MonoBehaviour {

    void OnTriggerEnter(){
        Debug.Log ("game over");

    }
}

2015年2月4日 星期三

unity - popular API


Transform

Time

Random

Mathf


Coroutine


========================

MonoBehaviour


========================


2015年2月3日 星期二

unity - camera transform, rotate, movement follow a ball

using UnityEngine;
using System.Collections;

public class BallCamera : MonoBehaviour

    public Transform target;   //needed to drag a rigidboady to target


    public float relativeHeigth = 10.0f;


    public float zDistance = 5.0f;
    //×èÄáËÙ¶È
    public float dampSpeed = 2;

    void Update()
    {

        Vector3 newPos = target.position + new Vector3(0relativeHeigth, -zDistance);


        transform.position = Vector3.Lerp(transform.positionnewPosTime.deltaTime * dampSpeed);
    }
}


======

FOrum about camera movement
http://forum.unity3d.com/threads/wow-camera-movement.16949/

unity - rigidbody arrow control by Keyboard


The value will be in the range -1...1 for keyboard and joystick input.

        horizontalMovement = Input.GetAxis("Horizontal") * Vector3.right * movementSpeed;
        verticalMovement = Input.GetAxis("Vertical") * Vector3.forward * movementSpeed;


        Vector3 movement = horizontalMovement + verticalMovement;


        rigidbody.AddForce(movementForceMode.Force);