0% found this document useful (0 votes)
8 views2 pages

Script Speed Ema Is

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Script Speed Ema Is

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// script 1

using UnityEngine;
using UnityEngine.InputSystem;
using System.Collections;
public class SpeedScript : MonoBehaviour
{
public InputActionProperty buttonPressed;
public float speed;
private Coroutine speedCoroutine;

private void OnEnable()


{
buttonPressed.action.Enable();
buttonPressed.action.performed += OnButtonPressed;
}

private void OnDisable()


{
buttonPressed.action.Disable();
buttonPressed.action.performed -= OnButtonPressed;
}

private void OnButtonPressed(InputAction.CallbackContext context)


{
if (context.performed)
{
if (speedCoroutine != null)
{
StopCoroutine(speedCoroutine);
}
speedCoroutine = StartCoroutine(IncreaseSpeedGradually());
}
}

private IEnumerator IncreaseSpeedGradually()


{
while (speed < 7f)
{
speed += Time.deltaTime;
yield return null;
}
}
}

-----------------------------------------------------------------------------------
// script 2
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Rotate : MonoBehaviour


{

public SpeedScript speedScript;

void Update()
{
gameObject.transform.Rotate(speedScript.speed,0,0);
}
}

You might also like