unity3d只有重力跟弹力为何会越跳越高
本人unity3d初学者,小球自由落体,给小球添加了重力跟弹力,落地后弹起会越弹越高是为何,按照物理上应该是一样高才是,求大虾解答,100分不成敬意。...
本人unity3d初学者,小球自由落体,给小球添加了重力跟弹力,落地后弹起会越弹越高是为何,按照物理上应该是一样高才是,求大虾解答,100分不成敬意。
展开
展开全部
摩擦必定会消耗一部分动能,一部分动能转移至热能,小球自由落体越弹越低.
physics engine编程错误,修改代码(Java或C#):
Update the code, it could working very good in my case.
Javascript:
#pragma strict
var firstTimeVelocitySave = false;
var savedVelocity : Vector3;
var myRigidbody : Rigidbody;
var BounceRate:float =1.5;
function OnCollisionEnter(col : Collision) {
//print("Collision! " + rigidbody.velocity);
if (! firstTimeVelocitySave) {
savedVelocity = rigidbody.velocity;
firstTimeVelocitySave = true;
}
myRigidbody.velocity.y = savedVelocity.y;
savedVelocity.y=savedVelocity.y/BounceRate;
}
C#
using UnityEngine;
using System.Collections;
public class ballBounce : MonoBehaviour {
private bool firstTimeVelocitySave = false;
private Vector3 savedVelocity;
//public Rigidbody myRigidbody ;
public float BounceRate =1.5f;
void OnCollisionEnter(Collision collision) {
//print("Collision! " + rigidbody.velocity);
if (! firstTimeVelocitySave) {
savedVelocity = rigidbody.velocity;
firstTimeVelocitySave = true;
}
//myRigidbody.velocity.y = savedVelocity.y;
// myRigidbody GameObject
gameObject.rigidbody.velocity =new Vector3(0,savedVelocity.y,0);
savedVelocity.y=savedVelocity.y/BounceRate;
}
}
physics engine编程错误,修改代码(Java或C#):
Update the code, it could working very good in my case.
Javascript:
#pragma strict
var firstTimeVelocitySave = false;
var savedVelocity : Vector3;
var myRigidbody : Rigidbody;
var BounceRate:float =1.5;
function OnCollisionEnter(col : Collision) {
//print("Collision! " + rigidbody.velocity);
if (! firstTimeVelocitySave) {
savedVelocity = rigidbody.velocity;
firstTimeVelocitySave = true;
}
myRigidbody.velocity.y = savedVelocity.y;
savedVelocity.y=savedVelocity.y/BounceRate;
}
C#
using UnityEngine;
using System.Collections;
public class ballBounce : MonoBehaviour {
private bool firstTimeVelocitySave = false;
private Vector3 savedVelocity;
//public Rigidbody myRigidbody ;
public float BounceRate =1.5f;
void OnCollisionEnter(Collision collision) {
//print("Collision! " + rigidbody.velocity);
if (! firstTimeVelocitySave) {
savedVelocity = rigidbody.velocity;
firstTimeVelocitySave = true;
}
//myRigidbody.velocity.y = savedVelocity.y;
// myRigidbody GameObject
gameObject.rigidbody.velocity =new Vector3(0,savedVelocity.y,0);
savedVelocity.y=savedVelocity.y/BounceRate;
}
}
追问
感谢,但是我问的是越来越高是什么情况
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你物理学好了吗,怎么可能会一样高,摩擦必定会消耗一部分动能
出现这种情况可能是你的阻力没有设置
出现这种情况可能是你的阻力没有设置
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
理想状态肯定是不应该高的,但实际可能小球落点不同,是否真的没有初速度,小球自身是否有弹力,弹力是否均匀等,这些可能都会有影响
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询