Home>

I'm currently making a shooting game, but I want to create a process that speeds up the player by pressing the move button while pressing space.

There is no error message displayed, but if you press → or ↑ and the ball is out, the speed will not increase even if you press space. ← and ↓ work properly, and in the case of AWDS operation, they work well.

Corresponding source code

``` Enter the language name here
C #
Source code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerControler: MonoBehaviour
{
public float HPlayerSpeed;// Fast player speed
public float LPlayerSpeed;// Slow player speed

public GameObject Tamaprefab;// Create a box to put pfefab

float spacetime;// sphere spacing
bool Tcount = true;// Sphere permission

// Start is called before the first frame update
void Start ()
{
spacetime = 0;
}

// Update is called once per frame
void Update ()
{
if (Input.GetKey (KeyCode.Space))
{
HPlayerSpeed ​​= 0.1f;
LPlayerSpeed ​​= 1;// Eliminate the effect on multiplication
Debug.Log ("dash");
}
else else
{
HPlayerSpeed ​​= 1;// Eliminate the effect on multiplication
LPlayerSpeed ​​= 0.05f;
}

if (Input.GetKey (KeyCode.LeftArrow) || Input.GetKey (KeyCode.A))
{
transform.Translate (HPlayerSpeed ​​* LPlayerSpeed ​​* -1, 0, 0);
}

if (Input.GetKey (KeyCode.RightArrow) || Input.GetKey (KeyCode.D))
{
transform.Translate (HPlayerSpeed ​​* LPlayerSpeed ​​* 1, 0, 0);
Debug.Log ("Move right");
}
if (Input.GetKey (KeyCode.UpArrow) || Input.GetKey (KeyCode.W))
{
transform.Translate (0, HPlayerSpeed ​​* LPlayerSpeed ​​* 1, 0);
Debug.Log ("Move up");
}
if (Input.GetKey (KeyCode.DownArrow) || Input.GetKey (KeyCode.S))
{
transform.Translate (0, HPlayerSpeed ​​* LPlayerSpeed ​​* -1, 0);
} // Character movement

if (Input.GetKey (KeyCode.Z) || Input.GetKey (KeyCode.L))
{if (Tcount == true)
{
spacetime + = Time.deltaTime;
Instantiate (Tamaprefab, transform.position, Quaternion.identity);// Generate things with Instantiate (what to make, position, rotation)
Tcount = false;
}
}
if (Tcount == false)
{
spacetime + = Time.deltaTime;
}
if (spacetime>0.1f)
{
Tcount = true;
spacetime = 0;
}

}
}

What I tried

Confirmation of tea ceremony by Debug.Log ()

Supplementary information (FW/tool version, etc.)

Please provide more detailed information here.