unity3d里面关于角度设置的问题 求解答
unity3d里面关于角度设置的问题问题1求ABC三点之间的角度问题2如何将一个物体(2D)锁定在一个角度区间(例如正负九十度之间)求具体求demo...
unity3d里面关于角度设置的问题
问题1 求 ABC 三点之间的角度
问题2 如何将一个物体(2D) 锁定在 一个角度区间(例如正负九十度之间) 求具体 求demo 展开
问题1 求 ABC 三点之间的角度
问题2 如何将一个物体(2D) 锁定在 一个角度区间(例如正负九十度之间) 求具体 求demo 展开
1个回答
2015-12-14
展开全部
using UnityEngine;
using System.Collections;
public class shibingkongzhi : MonoBehaviour {
public Texture2D[] shenti;
public Texture2D[] jiao;
public bool pd=false;
private shibingtuei tuei;
private shinbingshenti shen;
private Transform transtuei;
private Transform transshen;
private GameObject game;
public lei start;//引用enum类型
// Use this for initialization
void Start () {
transtuei=transform.FindChild("shibing");
transshen=transform.FindChild("jiao");
shen =transshen.GetComponent("shinbingshenti")as shinbingshenti;
tuei=transtuei.GetComponent("shibingtui")as shibingtuei;
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.A)){
start=lei.leftwalk;
pd=true;
}
if(Input.GetKeyDown(KeyCode.D)){
start=lei.rightwalk;
pd=false;
}
switch(start){
case lei.leftwalk:
user(shenti,jiao,pd);
break;
case lei.rightwalk:
user(shenti,jiao,pd);
break;
default:
break;
}
}
void user(Texture2D[] a,Texture2D[] b,bool car){
shen.fame=a;//fametuextrue2D[]
tuei.fame=b;//fametuextrue2D[]
if(car){
shen.pd=true;
tuei.pd=true;
}else{
shen.pd=false;
tuei.pd=false;
}
return;
}
}
提示错误:
NullReferenceException: Object reference not set to an instance of an object
shibingkongzhi.user (UnityEngine.Texture2D[] a, UnityEngine.Texture2D[] b, Boolean car) (at Assets/Scripts/shibing/shibingkongzhi.cs:46)
shibingkongzhi.Update () (at Assets/Scripts/shibing/shibingkongzhi.cs:39)
我怀疑user函数声明误知道改求神解答
using System.Collections;
public class shibingkongzhi : MonoBehaviour {
public Texture2D[] shenti;
public Texture2D[] jiao;
public bool pd=false;
private shibingtuei tuei;
private shinbingshenti shen;
private Transform transtuei;
private Transform transshen;
private GameObject game;
public lei start;//引用enum类型
// Use this for initialization
void Start () {
transtuei=transform.FindChild("shibing");
transshen=transform.FindChild("jiao");
shen =transshen.GetComponent("shinbingshenti")as shinbingshenti;
tuei=transtuei.GetComponent("shibingtui")as shibingtuei;
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.A)){
start=lei.leftwalk;
pd=true;
}
if(Input.GetKeyDown(KeyCode.D)){
start=lei.rightwalk;
pd=false;
}
switch(start){
case lei.leftwalk:
user(shenti,jiao,pd);
break;
case lei.rightwalk:
user(shenti,jiao,pd);
break;
default:
break;
}
}
void user(Texture2D[] a,Texture2D[] b,bool car){
shen.fame=a;//fametuextrue2D[]
tuei.fame=b;//fametuextrue2D[]
if(car){
shen.pd=true;
tuei.pd=true;
}else{
shen.pd=false;
tuei.pd=false;
}
return;
}
}
提示错误:
NullReferenceException: Object reference not set to an instance of an object
shibingkongzhi.user (UnityEngine.Texture2D[] a, UnityEngine.Texture2D[] b, Boolean car) (at Assets/Scripts/shibing/shibingkongzhi.cs:46)
shibingkongzhi.Update () (at Assets/Scripts/shibing/shibingkongzhi.cs:39)
我怀疑user函数声明误知道改求神解答
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询