游戏对象运动简述

游戏对象运动简述

  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++;
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值