What I am trying to do is boost the speed in the paddle by pressing a button in Block Breaker. My last post was closed so I had to make a new one.
Here is the code I am using.
‘’'public class MoveLR : MonoBehaviour
{
public float PlayerSpeed = 5;
bool mofe = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float amtToMove = Input.GetAxis("Horizontal") * PlayerSpeed * Time.deltaTime;
transform.Translate(Vector3.right * amtToMove);
}
private void Mofast()
{
if (CrossPlatformInputManager.GetButtonDown("Fire1"))
{
PlayerSpeed = 20f;
}
}
Try to explain your issue as detailed as possible, because I don’t know what I’m answering here so I’ll end up writing a wall of text without even knowing if that’ll help you.
From what I’m seeing your idea is lacking many things.
Game Design Wise
Have you considered a cooldown? The code shown in the links provided should work, but you can spam the button and keep the speed boost forever, not sure if that’s what you are going for.
CodeWise
Your Mofast method isn’t being called anywhere, that should be called inside an update call.
The speed will remain at 20, it will never get back to the default, which according to your code is 5.
Here’s an easy example of how to make it work with a cooldown, not my favorite approach, but a simple to understand one based on what you already researched.
Thank you. I had gotten injured & wasn’t able to do anything for a few. I’m going to try this today. If it does not work I will explain everything & get it started. I’m sorry for the delay.