- Home /
Question by
Inventor-2 · Dec 30, 2011 at 08:32 PM ·
speedissuefullscreenwallthrough
In fullscreen mode the player is moving faster/He is walking through walls
Hello, When I move my character in my built game, it causeless moves faster then in the editor(Only in fullscreen-mode on a Mac). The character is also walking through walls.(Both have a collider) This is my walking script:
var walkspeed = 1.0;
function Start ()
{
animation.wrapMode = WrapMode.PingPong;
animation.CrossFade ("idle");
}
function Update () {
transform.Rotate(0,Input.GetAxis("Mouse X"),0) ;
verMovement = Input.GetAxis("Vertical");
horMovement = Input.GetAxis("Horizontal");
if (Input.GetKeyDown("space") && Physics.Raycast(transform.position, -transform.up,2))
{
rigidbody.AddRelativeForce(transform.up * 110, ForceMode.Impulse);
}
if (Input.GetKey("space")){
animation.wrapMode = WrapMode.Once;
animation.CrossFade("jump");
}else{
if (Physics.Raycast(transform.position, -transform.up,2) == false){
animation.wrapMode = WrapMode.PingPong;
animation.CrossFade("fall");
}
else{
animation.wrapMode = WrapMode.Loop;
if ((Input.GetAxis("Horizontal") + Input.GetAxis("Vertical") )&& Physics.Raycast(transform.position, -transform.up,2)) {
animation.CrossFade ("walk");
}else {
animation.wrapMode = WrapMode.PingPong;
animation.CrossFade ("idle");
}}}
if (horMovement) {
transform.Translate((Vector3.right * horMovement) * walkspeed);
}
if(verMovement) {
transform.Translate((Vector3.forward * verMovement) * walkspeed);
}
}
I couldn't found a solution for this.
Sorry for English mistakes. Thanks. Inventor
Comment
Answer by Silverfell 1 · Dec 31, 2011 at 12:39 AM
A liberal sprinkle of Time.deltaTime will fix all speed-related issues.
There are many topics through this resource that detail the use of deltaTime, but the short version is this: if you want to ensure consistency across platforms/systems/resolutions/GPUs, every time you move anything, multiply it by Time.deltaTime.
Turning:
transform.Translate((Vector3.right * horMovement) * walkspeed);
into:
transform.Translate((Vector3.right * horMovement) * walkspeed * Time.deltaTime);
should fix your problem :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613062515im_/https://answers.unity.com/themes/thub/images/avi.jpg)