live2d碰撞_两个相同Prefab实例之间的碰撞检测

我试图重建超级马里奥兄弟的第一阶段,但是我在Koopa Shells之间的碰撞系统上遇到了一些麻烦。

我写了两个不同的脚本,希望达到这个目的:

这第一个脚本是处理基本运动,并开始在球员碰撞壳运动

public class KoopaShell : MonoBehaviour { //Makes this accessible to other Scripts static public bool Moving; // Boolean Flags to be inherited public bool isMoving; bool shellLeft, shellRight, rightBlocked, leftBlocked; public float rayDis; public LayerMask enemyMask; public Transform rCast; BoxCollider rayHold; ConstantForce2D cf; float myWidth, myHeight; Rigidbody2D rb; Ray rRay, lRay; Transform myTrans; Vector2 myVel; [SerializeField] RaycastHit hitinfo; // Start is called once at the beginning of run time void Start() { // Sets our shorthanded variables equal to the KoopaShell's Rigid Body and position; myTrans = this.transform; rb = this.gameObject.GetComponent(); //Ignores Collision Between the level boundaries/ power ups and the Koppa Shell Physics2D.IgnoreLayerCollision(9, 12); Physics2D.IgnoreLayerCollision(11, 12); // This is a variable to help short hand us accessing our Sprite Renderer component SpriteRenderer mySprite = this.gameObject.GetComponent(); // These two variables are using the mySprite varaible to access the extents or total midway point of the sprite in both the x and y axis myWidth = mySprite.bounds.extents.x;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值