赞
踩
直接拖拽进Scene或者,Hierarchy创建Sprite,将角色素材拖动到Sprite Renderer–Sprite;
添加刚体Rigidbody 2D(Linear Drag:阻力 Gravity Grag:重力);
添加碰撞体Box Collider;给地图添加碰撞体Tilemap Collider 2D;
待定
选中player,添加(add component)Animator。在文件夹中创建 Animator Controller,拖到Animator的Controller部分。
添加具体的动画效果:window里选择Animation(ctrl 6),选中player 创建动画(Create)(下一次创建点击Samples左边下拉框,点击Creat new clip)。将图片拖到时间轴里。调整速度:在时间轴拉长动画或者调整采样频率(右上角,show samples rate)。
window–Animator
右键动画添加Transition,点击Transition设置条件(在Parameters中添加参数后,可在设置转换条件时使用)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerControler : MonoBehaviour { public Rigidbody2D rb; public Animator anim; public Collider2D coll; public float speed; public float jumpforce; public LayerMask ground; // Start is called before the first frame update void Start() { } // Update is called once per frame void FixedUpdate() { } void Update() { Movement(); SwitchAnim(); } void Movement() { float horizontalmove = Input.GetAxis("Horizontal")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。