Android上的统一跳跃高度不同

Android上的统一跳跃高度不同,android,unity3d,game-physics,Android,Unity3d,Game Physics,我想不出来。我的力量放在了FixedUpdate()函数中,但我在android上的跳跃速度仍然是在PC上的3倍。我做错什么了吗?fixedupdate不应该确保它不是fps问题吗?还是基于屏幕分辨率 using UnityEngine; using System.Collections; public class CharacterControllerScript : MonoBehaviour { public KeyCode up; public KeyCode down; publ

我想不出来。我的力量放在了FixedUpdate()函数中,但我在android上的跳跃速度仍然是在PC上的3倍。我做错什么了吗?fixedupdate不应该确保它不是fps问题吗?还是基于屏幕分辨率

using UnityEngine;
using System.Collections;

public class CharacterControllerScript : MonoBehaviour {

public KeyCode up;
public KeyCode down;

public float maxSpeed = 10f;
public bool facingRight = true;
public float tiltSpeed = 10f;
public float filter = 5.0f;
public float accelerationSpeed = 10f;
public bool jump = false;


private Vector3 accel;

Animator anim;

public bool grounded = false;
public Transform groundCheck;
float groundRadius = 0.2f;
public LayerMask whatIsGround;
public float jumpForce = 700;

// Use this for initialization
void Start () {
   anim = GetComponent<Animator>();
   accel = Input.acceleration;
}

// Update is called once per frame
void FixedUpdate () {

   grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
   anim.SetBool("Ground", grounded);

   anim.SetFloat ("vSpeed", rigidbody2D.velocity.y);


   /*if (grounded && ((Input.GetKeyDown(up)) || Input.touchCount == 1)) 
     rigidbody2D.AddForce(new Vector2(0, Mathf.Clamp(jumpForce, 0, 700)));
   */
   if(jump){
     rigidbody2D.AddForce(new Vector2(0, jumpForce));
     //rigidbody2D.AddForce (new Vector2(0, jumpForce) * rigidbody2D.mass / Time.fixedDeltaTime);
   }

   // Set animation
   if ((Application.platform == RuntimePlatform.Android) || (Application.platform == RuntimePlatform.IPhonePlayer)){
     // filter the jerky acceleration in the variable accel:
     accel = Vector3.Lerp(accel, Input.acceleration, filter * Time.deltaTime);
     // map accel -Y and X to game X and Y directions:
     Vector3 dir = new Vector3(Mathf.Clamp(accel.x, -accelerationSpeed, accelerationSpeed), 0, 0);
     // limit dir vector to magnitude 1:
     if (dir.sqrMagnitude > 1) dir.Normalize();
     // move the object at the velocity defined in speed:
     transform.Translate(dir * tiltSpeed * Time.deltaTime);
     anim.SetFloat("Speed", Mathf.Abs(dir.sqrMagnitude * tiltSpeed));
     if (Input.acceleration.x > 0 && !facingRight)
      Flip ();
     else if (Input.acceleration.x < 0 && facingRight)
      Flip ();
   }
   else {
     float move = Input.GetAxis ("Horizontal");
     anim.SetFloat("Speed", Mathf.Abs(move));
     rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);

     // Decide what way animation moving
     if (move > 0 && !facingRight)
      Flip ();
     else if (move < 0 && facingRight)
      Flip ();
   }
   jump = false;
}

void Flip () {
   facingRight = !facingRight;
   Vector3 thescale = transform.localScale;
   thescale.x *= -1;
   transform.localScale = thescale;
}

void Update () {
   if(grounded && ((Input.GetKeyDown(up)) || Input.touchCount == 1)){
     anim.SetBool("Ground", false);
     //rigidbody2D.AddForce(new Vector2(0, jumpForce * Time.fixedDeltaTime));
     jump = true;
   }
 }
}
使用UnityEngine;
使用系统集合;
公共类CharacterControllerScript:MonoBehavior{
公钥密码;
公钥密码关闭;
公共浮点数maxSpeed=10f;
公共bool facingRight=正确;
公众浮子倾斜速度=10f;
公共浮子过滤器=5.0f;
公众浮子加速速度=10f;
公共布尔跳跃=假;
私人矢量3加速器;
动画师;
公共布尔值=假;
公开审查;
浮地半径=0.2f;
公共层码头;
公众浮力=700;
//用于初始化
无效开始(){
anim=GetComponent();
加速度=输入加速度;
}
//每帧调用一次更新
无效固定更新(){
接地=物理2D.重叠圆(接地检查位置、接地半径、whatIsGround);
动画设置工具(“地面”,接地);
anim.SetFloat(“vSpeed”,rigiidbody2d.velocity.y);
/*if(接地&((Input.GetKeyDown(up))| | Input.touchCount==1))
rigidbody2D.AddForce(新矢量2(0,数学夹具(jumpForce,0,700));
*/
如果(跳转){
刚度矢量2d.AddForce(新矢量2(0,跳跃力));
//rigidbody2D.AddForce(新矢量2(0,跳跃力)*rigidbody2D.mass/Time.fixedDeltaTime);
}
//设置动画
if((Application.platform==RuntimePlatform.Android)| |(Application.platform==RuntimePlatform.IPhonePlayer)){
//过滤可变加速度中的急促加速度:
accel=Vector3.Lerp(accel,Input.acceleration,filter*Time.deltaTime);
//将加速度-Y和X映射到游戏X和Y方向:
Vector3 dir=新的Vector3(数学钳位(加速度x,-加速度速度,加速度速度),0,0);
//将dir矢量限制为1级:
如果(dir.sqrMagnitude>1)dir.Normalize();
//以“速度”中定义的速度移动对象:
transform.Translate(dir*tiltSpeed*Time.deltaTime);
动画设置浮动(“速度”,数学绝对值(方向sqrMagnitude*倾斜速度));
如果(Input.acceleration.x>0&&!facingRight)
翻转();
else if(输入.加速度.x<0&&facingRight)
翻转();
}
否则{
浮动移动=Input.GetAxis(“水平”);
动画设置浮动(“速度”,数学Abs(移动));
rigidbody2D.velocity=新矢量2(移动*最大速度,rigidbody2D.velocity.y);
//决定动画移动的方式
如果(移动>0&!朝向右侧)
翻转();
else if(移动<0&&朝向右侧)
翻转();
}
跳跃=假;
}
无效翻转(){
facingRight=!facingRight;
Vector3 thescale=transform.localScale;
比例x*=-1;
transform.localScale=比例;
}
无效更新(){
if(接地&((Input.GetKeyDown(up))| | Input.touchCount==1)){
动画设置工具(“地面”,假);
//rigidbody2D.AddForce(新矢量2(0,jumpForce*Time.FixedDelatime));
跳跃=真;
}
}
}

那么你在运行不同的android代码,然后在PC上运行,…是的。。。当你在Android/Iphone上执行
transform.translate
,在其他所有设备(包括pc)上执行
rigidbody2D.velocity
时,你到底希望得到什么样的结果?