美文网首页
90.小球项目相关技术总结

90.小球项目相关技术总结

作者: cmd_ts | 来源:发表于2019-01-16 16:42 被阅读11次

代码:https://gitee.com/cmd_develop/unity_ball_roll

333.png

1.text 文字更改
public Text text;
text.text = "成绩:" + score.ToString();

2.节点的显示与隐藏
public GameObject win_text;
win_text.SetActive(true);
win_text.SetActive(false);

3.节点的删除
void OnTriggerEnter(Collider other)
{
Destroy(other.gameObject);
}

4.触发检测(只触发不碰撞)
void OnTriggerEnter(Collider other)
{
if(other.tag == "food"){xxx}
}


image.png

5.碰撞检测,注意把第四点的触发器给关闭


1.png

6.相机跟随
void Start()
{
offset = transform.position - ball.position;
}
// Update is called once per frame
void Update()
{
transform.position = ball.position + offset;
}

7.物品旋转
transform.Rotate(new Vector3(0,1,0));

相关文章

网友评论

      本文标题:90.小球项目相关技术总结

      本文链接:https://www.haomeiwen.com/subject/yvimdqtx.html