球球大作战 01 小球的移动和碰到金币,金币会消失。

球球大作战 01 小球的移动和碰到金币,金币会消失。

版权申明:

本文原创首发于以下网站:

博客园『优梦创客』的空间:https://www.cnblogs.com/raymondking123

优梦创客的官方博客:https://91make.top

优梦创客的游戏讲堂:https://91make.ke.qq.com

『优梦创客』的微信公众号:umaketop

您可以自由转载,但必须加入完整的版权声明!

球球大作战小球的移动和碰到金币,金币会消失。

吃到金币

public class SphereMove : MonoBehaviour

{

public float Spheremove = 20;

public float Spherejump = 50;

// Start is called before the first frame update

void Start()

{

}

// Update is called once per frame

void Update()

{

if (Input.GetKey(KeyCode.UpArrow))

{

GetComponent().AddForce(Spheremove, 0, 0);

}

if (Input.GetKey(KeyCode.DownArrow))

{

GetComponent().AddForce(-Spheremove, 0, 0);

}

if (Input.GetKey(KeyCode.LeftArrow))

{

GetComponent().AddForce(0, 0, Spheremove);

}

if (Input.GetKey(KeyCode.RightArrow))

{

GetComponent().AddForce(0, 0, -Spheremove);

}

if (Input.GetKey(KeyCode.Space))

{

GetComponent().AddForce(0, Spherejump, 0);

}

}

public void OnTriggerEnter(Collider other)

{

if (other.gameObject.tag == ("Goodup"))

{

other.gameObject.SetActive(false);

}

}

}

金币围绕Y轴转动金币围绕Y轴转动。

public class Pickupsctrl : MonoBehaviour

{

public Vector3 rot;

// Start is called before the first frame update

void Start()

{

}

// Update is called once per frame

void Update()

{

rot = new Vector3(0, 20, 0);

rot = rot* Time.deltaTime;

transform.Rotate(rot);

}

}

相机跟随小球移动相机跟随小球移动。

public class Canearctrl : MonoBehaviour

{

public Vector3 Offset;

public Transform player;

// Start is called before the first frame update

void Start()

{

Offset = this.transform.position - player.position;

}

// Update is called once per frame

void Update()

{

this.transform.position = player.position + Offset;

}

}

相关推荐

国家生态系统观测研究网络
精准原创123656官方网

国家生态系统观测研究网络

📅 10-09 👁️ 2019
汉字:「高」 字形演变 字源演变
精准原创123656官方网

汉字:「高」 字形演变 字源演变

📅 07-03 👁️ 3497
喝什么解酒汤解酒快
365游戏注册

喝什么解酒汤解酒快

📅 07-25 👁️ 6635
DNF九周年袖珍罐给哪些职业 给这些职业最划算
365游戏注册

DNF九周年袖珍罐给哪些职业 给这些职业最划算

📅 09-15 👁️ 2081
角色扮演游戏有哪些好玩 十大必玩角色扮演游戏精选
精准原创123656官方网

角色扮演游戏有哪些好玩 十大必玩角色扮演游戏精选

📅 11-14 👁️ 9782
手机听筒音量怎么调
精准原创123656官方网

手机听筒音量怎么调

📅 11-03 👁️ 8174
钞好用审核要多久 钞好用好下款吗
365bet体育在线赌场

钞好用审核要多久 钞好用好下款吗

📅 10-20 👁️ 9633
EVO历年比赛项目入选游戏推荐
365游戏注册

EVO历年比赛项目入选游戏推荐

📅 02-02 👁️ 9628
红豆薏米水要煮多久 红豆薏米水的正确做法
365游戏注册

红豆薏米水要煮多久 红豆薏米水的正确做法

📅 07-16 👁️ 6903