第一步:google搜索trump low poly model下载model
image.pngimage.png
下载trump model
image.png
将压缩包解压,将LowpolyTrump导入Unity
ji
将Anims目录下的trump_ip_anim_iddle01拖入hierarchy视图ImageTarget下,让它成为ImageTarget的子节点,选中修改component
image.png
第二步:Assets->Import Package->CrossPlatformInput
将MobileSingleStickControl拖入Hierarchy视图,删除下面的JumpButton
选中MobileJoystick修改参数
将Standard Assets下的CrossPlatformInput下的Prefabs中的MobileSingleStickControl拖入Hierarchy中
修改MobileJoystick的component
第三步:将trump的idle,walk动画的AnimationType 修改为Legacy
选中Anims下的Idle model,在Inspector中选中Rig选项卡
image.png
修改模型动画为Legacy
展开idle动画选中Take 001点击Inspector视图中的Edit
image.png
修改动画名称为idle,Wrap Mode为Loop,Walk动画同理
image.png
再次选中trump_lp_anim_iddle01,在Inspector中修改Animations Size为2,将walk拖入Element1
image.png
添加RigidBody组件 uncheck Use Gravity
image.png
4.新建TrumpController.cs,拖入trump_lp_anim_iddle01中,成为其组件
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class TrumpController : MonoBehaviour {
private Rigidbody rb;
private Animation anim;
// Use this for initialization
void Start() {
rb = GetComponent<Rigidbody>();
anim = GetComponent<Animation>();
}
// Update is called once per frame
void Update() {
float x = CrossPlatformInputManager.GetAxis("Horizontal");
float y = CrossPlatformInputManager.GetAxis("Vertical");
Vector3 movement = new Vector3(x, 0, y);
rb.velocity = movement * 4f;
if (x != 0 && y != 0)
{
transform.eulerAngles = new Vector3(transform.eulerAngles.x, Mathf.Atan2(x, y) * Mathf.Rad2Deg, transform.eulerAngles.z);
}
if (x != 0 || y!=0)
{
anim.Play("walk");
}
else
{
anim.Play("idle");
}
}
}
5.运行游戏
MatthewHallberg视频地址:Lets Make an Augmented Reality App in 6 MINUTES!!!! DONALD TRUMP EDITION
网友评论