41705人加入学习
(116人评价)
Unity零基础入门 - 打砖块(Unity 2017) - 旧版
价格 免费

场景由物体组成

物体之间存在父子关系

游戏物体由组件组成

transform:position、旋转角度、大小

组件分为:信息组件、功能组件

[展开全文]

设置墙体,设置子弹,设置相机位置,子弹从相机位置产生(Instantiate) (子弹和墙需有刚体和碰撞体),给子弹速度(velocity)控制相机左右及上下移动即可(transform.Translate)

[展开全文]

https://pan.baidu.com/s/1ljmju3axWZuzupxPE4_umg

提取码   

[展开全文]

相机:gizmos滑动条缩小放大

相机拍到的东西是要展示给玩家的东西

锥形是视野范围

游戏物体可以层级存放,有父子关系

 

[展开全文]

正交视野下:

按住鼠标右键拖动和转向

alt+左键围绕前方旋转

gameobject

双击聚焦,滑轮放大缩小

红x蓝y黄z

右键选择3Dobject

hearcy

按住鼠标中键平移

推动y轴可摆放高度

Ctrl+d复制cube

[展开全文]

unity官网:unity.com和unity3d.com

免费版不可用于商用只可以学习

[展开全文]

ctrl+D 复制 ctrl+拖动 按照1米的进行移动

添加物理引擎 rigidbody

 

创建模板prefabs (预制体),拖动到scene上就会创建实例

[展开全文]

设置地面  plan 设置位置 0,0,0

第二种方式 使用cube  用reset设置初始位置

用按键r调节大小

调节天空的颜色,在camara哪里 

修改地面的颜色 材制  金属和光滑度

[展开全文]

拖动SPHERE为Bullet赋值

//Input.GetMouseButtonDown为检测鼠标状态,0为左键
        if(Input.GetMouseButtonDown(0))
        {

// Instantiate可以实例化目标,脚本shoot为相机的组件,所以transform.position代表指定位置为当前相机位置,第三个为旋转
            GameObject.Instantiate(bullet, transform.position, transform.rotation);
        }
   

[展开全文]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript2 : MonoBehaviour
{
    public float speed = 3;
    // Start is called before the first frame update
    void Start()
    {
       
    }
    // Update is called once per frame
    void Update()
    {
       float h= Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        //Debug.Log(h);按左返回负值
        transform.Translate(new Vector3(h,v,0)*Time.deltaTime*speed);
    }
}
[展开全文]

给子弹初速度

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript1 : MonoBehaviour
{
    public GameObject bullet;//一定要确保bullet赋值了,在unity里面赋值
    public float speed = 5;  //这里定义在inspector面板很容易修改,以面板为准
    // Start is called before the first frame update
    void Start()
    {
       
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))//按下鼠标左键实例化
        {
          GameObject b=  GameObject.Instantiate(bullet, transform.position, transform.rotation);//实例化一个子弹
            Rigidbody rgd = b.GetComponent<Rigidbody>();//得到物体刚体组件
            rgd.velocity = transform.forward * speed;
        }
    }
}
[展开全文]

子弹实例化

public class Movement : MonoBehaviour
{
    public GameObject bullet;//一定要确保bullet赋值了,在unity里面赋值
    // Start is called before the first frame update
    void Start()
    {
       
    }
    // Update is called once per frame
    void Update()
    {
    if(Input.GetMouseButtonDown(0))//按下鼠标左键实例化
        {
            GameObject.Instantiate(bullet, transform.position, transform.rotation);//实例化一个子弹
        }
    }
}

[展开全文]

控制摄像机左右移动

为摄像机移动添加一个新的脚本Movement

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript2 : MonoBehaviour
{
    public float speed = 3;
    // Start is called before the first frame update
    void Start()
    {
       
    }
    // Update is called once per frame
    void Update()
    {
       float h= Input.GetAxis("Horizontal");
        //Debug.Log(h);按左返回负值
        transform.Translate(new Vector3(h,0,0)*Time.deltaTime*speed);
    }
}
[展开全文]

Debug.Log("Hello,unity");

打开控制台Window

 

[展开全文]

授课教师

加我的QQ问问题:804632564

课程特色

图文(2)
下载资料(1)
视频(19)

学员动态