求教!跳跃代码报错
原案例是基于Unity4的,我用的是Unity5
#70和#89行报错,原因是jumpMaterial没有定义。说实话这段代码我理解不了为什么要这样设计,求高人指点

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayController : MonoBehaviour {
[HideInInspector]
public bool isFacingRight = true;
[HideInInspector]
public bool isJumping = false;
[HideInInspector]
public bool isDoubleJumping = false;
[HideInInspector]
public bool isGrounded = false;
public float jumpForce = 650.0f;
public float maxSpeed = 7.0f;
public Transform groundCheck;
public LayerMask groundLayers;
private float groundCheckRadius = 0.2f;
private Animator anim;
void awake(){
anim = GetComponent<Animator> ();
}
// // Use this for initialization
// void Start () {
// }
// Update is called once per frame
void Update () {
if (Input.GetButtonDown ("Jump"))
{
if (isGrounded == true) {
this.GetComponent<Rigidbody2D> ().velocity = new Vector2 (GetComponent<Rigidbody2D> ().velocity.x, 0);
this.GetComponent<Rigidbody2D> ().AddForce (new Vector2 (0, jumpForce));
this.anim.SetTrigger ("Jump");
} else if (isDoubleJumping == false) {
isDoubleJumping = true;
this.GetComponent<Rigidbody2D> ().velocity = new Vector2 (GetComponent<Rigidbody2D> ().velocity.x, 0);
this.GetComponent<Rigidbody2D> ().AddForce (new Vector2 (0, jumpForce));
}
}
}
private void FixedUpdate()
{
isGrounded = Physics2D.OverlapCircle
(groundCheck.position, groundCheckRadius, groundLayers);
PhysicsMaterial2D material = this.gameObject.GetComponent<CircleCollider2D> ().sharedMaterial;
if(isGrounded==true)
{
isDoubleJumping=false;
}
if (isGrounded == true && material == this.jumpMaterial) {
CircleCollider2D collision = this.gameObject.GetComponent<CircleCollider2D> ();
collision.sharedMaterial = null;
collision.enabled = false;
collision.enabled = true;
}
else if(isGrounded ==false&&this.gameObject.GetComponent<CircleCollider2D>().sharedMaterial==null)
{
CircleCollider2D collision = this.gameObject.GetComponent<CircleCollider2D> ();
collision.sharedMaterial = this.jumpMaterial;
collision.enabled = false;
collision.enabled = true;
}
float move = Input.GetAxis ("Horizontal");
try
{
this.GetComponent<Rigidbody2D>().velocity = new Vector2 (move * maxSpeed, GetComponent<Rigidbody2D>().velocity.y);
this.anim.SetFloat("Speed",Mathf.Abs(move));
if ((move > 0.0f && isFacingRight == false)|| (move < 0.0f && isFacingRight == true))
{
Flip ();
}
}
catch(UnityException error){
Debug.LogError (error.toString ());
}
}
void Flip()
{
isFacingRight = !isFacingRight;
Vector3 playerScale = transform.localScale;
playerScale.x = playerScale.x * -1;
transform.localScale = playerScale;
}
}
相关推荐
leetcode跳跃游戏的应用场景-leetcode:leetcode
leetcode跳跃游戏的应用场景 leetcode 注意事项 leetcode上会进行很多的代码检测,未初始化、初始化不完全等会导致各种奇奇怪怪的内存报错。所以在使用变量、创建结构体时一定要对其进行初始化!!! 一、DFS 判断树是否是满足某种关系(true or false),如是否是搜索树、是否对称,一般使用前中后序遍历可解决问题 寻找树中的某种参数,如树的深度、某种组合等 利用二叉树、遍历的某种性质解决问题,如根据便利结果构造二叉树 note:前序遍历的结果中,第一个元素是根节点的值,后面依次是左子树和右子树,每一个子树都符合这种结构;对于中序和后续遍历,唯一的不同是根节点位于中间和最后 前序遍历:[root node,(left subtree),(right subtree)] 中序遍历:[(left subtree),root node,(right subtree)] 后序遍历:[(left subtree),(right subtree),root node] 二、BFS 二叉树的层序遍历,一般用队列实现 不是二叉树,但可以转换成二叉树的问题解决 三、二分搜索(比较考
RƎ跳跃1.01unity3d 资源U3d插件
RƎ跳跃1.01unity3d 资源U3d插件 Unity游戏源码 , Unity项目源码 , Unity小游戏源码 是个Unitypackage包 , 直接创建空项目导入就行了 , 适合二次开发和学习使用 如果报错请切换一下编译器版本就行 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U3d插件 RƎ跳跃1.01unity3d 资源U
mrantifun_v1.1.0.0_xitongcheng (1).zip
mrantifun_v1.1.0.0_xitongcheng (1).zip
1P09109报错日志
1P09109报错日志
Oracle数字类型number自增的实现代码
主要介绍了Oracle数字类型number自增的实现代码,需要的朋友可以参考下


