Lets Make an Augmented Reality A
2018-03-27 本文已影响0人
android小菜鸡一枚

第一步:google搜索trump low poly model下载model


下载trump model

将压缩包解压,将LowpolyTrump导入Unity

将Anims目录下的trump_ip_anim_iddle01拖入hierarchy视图ImageTarget下,让它成为ImageTarget的子节点,选中修改component

第二步:Assets->Import Package->CrossPlatformInput
将MobileSingleStickControl拖入Hierarchy视图,删除下面的JumpButton
选中MobileJoystick修改参数


第三步:将trump的idle,walk动画的AnimationType 修改为Legacy
选中Anims下的Idle model,在Inspector中选中Rig选项卡


展开idle动画选中Take 001点击Inspector视图中的Edit

修改动画名称为idle,Wrap Mode为Loop,Walk动画同理

再次选中trump_lp_anim_iddle01,在Inspector中修改Animations Size为2,将walk拖入Element1

添加RigidBody组件 uncheck Use Gravity

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