游戏对象运动简述

游戏对象运动简述

  1. 游戏对象运动的本质是什么?

    游戏对象运动其实就是游戏对象在每一帧空间位置的变化,由于是3d物体,这里的位置不仅包括了对象的三维坐标系,还包括了对象的Rotation



  1. 用三种方法实现物体的抛物线运动
    根据抛物线的公式
    S y = v y t − g t 2 S_y = v_yt-gt^2 Sy=vytgt2
    S x = v x t S_x = v_xt Sx=vxt
    每一时刻给x,y轴增加一个 Δ x Δx Δx Δ y Δy Δy
    三种方法如下:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
     
    public class Parabolic : MonoBehaviour {
     
        public float speed = 5;   // 移动速度
    	// Use this for initialization
    	void Start () {
    	}
    	
    	// Update is called once per frame
    	void Update () {
            Vector3 delta_vector = new Vector3(Time.deltaTime*5, -Time.deltaTime*(speed/10), 0);
            this.transform.position += delta_vector;
            speed++;
    	}
    }
    


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Parabolic : MonoBehaviour {
 
    public float speed = 1;
	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
 
        Vector3 delta_vector = new Vector3(Time.deltaTime * 5, -Time.deltaTime * (speed / 10), 0);
        transform.Translate(delta_vector);
        speed++;
    }
}


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class move1 : MonoBehaviour {
 
    public float speed = 1;
	// Use this for initialization
	void Start () {
        Debug.Log("start!");
	}
	
	// Update is called once per frame
	void Update () {
 
        this.transform.position += Vector3.down * Time.deltaTime * (speed/10);
        this.transform.position += Vector3.right * Time.deltaTime * 5;
        speed++;
	}
}

猜你喜欢

转载自blog.csdn.net/weixin_51930942/article/details/127479292