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

Unity Speed and Rotation Scripts

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)
41 views2 pages

Unity Speed and Rotation Scripts

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

// script 1

using UnityEngine;
using [Link];
using [Link];
public class SpeedScript : MonoBehaviour
{
public InputActionProperty buttonPressed;
public float speed;
private Coroutine speedCoroutine;

private void OnEnable()


{
[Link]();
[Link] += OnButtonPressed;
}

private void OnDisable()


{
[Link]();
[Link] -= OnButtonPressed;
}

private void OnButtonPressed([Link] context)


{
if ([Link])
{
if (speedCoroutine != null)
{
StopCoroutine(speedCoroutine);
}
speedCoroutine = StartCoroutine(IncreaseSpeedGradually());
}
}

private IEnumerator IncreaseSpeedGradually()


{
while (speed < 7f)
{
speed += [Link];
yield return null;
}
}
}

-----------------------------------------------------------------------------------
// script 2
using [Link];
using [Link];
using UnityEngine;

public class Rotate : MonoBehaviour


{

public SpeedScript speedScript;

void Update()
{
[Link]([Link],0,0);
}
}

You might also like