unity3d day4 (Time-based, Random class, Mathf class)

A, Time class

  Role: to ensure the uniform movement of the object. Time.deltaTime

  1 for controlling the moving velocity

  2. solve Update () method causes the influence of the frame rate of each frame when the case of moving a different time.

Using Translate () method

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TimeDemo : MonoBehaviour {

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {

        this.transform.Translate(Vector3.up * Time.deltaTime);

	}
}

 Using Rorate () method

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TimeDemo : MonoBehaviour {

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {

        this.transform.Rotate(Vector3.down * Time.deltaTime);

	}
}

 

Guess you like

Origin www.cnblogs.com/wxd623510693/p/11109620.html