You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity 2D paddle and ball游戏球受 paddle 摆动弹跳异常问题咨询

Unity 弹板击球游戏物理异常问题

我正在开发一款基于Unity的弹板击球衍生游戏,机制是弹板(paddle)将球弹起并朝自身朝向击打。目前游戏基础功能正常:弹板会随惯性旋转,朝转向方向击球;静止状态下球每次弹跳高度一致(符合预期),但摆动弹板击球时,球会弹得极高且轨迹混乱。

物理设置与对象状态

  • 物理材质"BallBounce":摩擦值0、弹力值1
  • 球未附加任何脚本

相关截图

  • 2D球及其Sphere Collider:2D球碰撞体
  • 弹板视图1:弹板截图1
  • 弹板视图2:弹板截图2

预期效果

我想要实现的物理效果参考自己用Python制作的同类型项目,核心是弹板摆动击球时,球的弹跳轨迹稳定,不会出现超高弹跳的异常情况。

弹板移动代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PaddleMove : MonoBehaviour
{
    private Rigidbody2D rb;

    void Start() 
    {
        rb = GetComponent<Rigidbody2D>();
    }

    public Vector3 mousePos;

    // Update is called once per frame
    void Update()
    {
        // Variables
        mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        GameObject paddle = GameObject.FindWithTag("Player");
        float xVelocity = rb.velocity.x;
        float rotationAngle = xVelocity / -2.5f;

        mousePos.y = transform.position.y;

        Vector2 moveDirection = (mousePos - transform.position).normalized;
        rb.velocity = moveDirection * 50f;

        transform.rotation = Quaternion.Euler(0f, 0f, rotationAngle);
    }
}

内容的提问来源于stack exchange,提问作者Not Rend3r

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 16:32:44