53 lines
1.6 KiB
C#
Executable file
53 lines
1.6 KiB
C#
Executable file
using UnityEngine;
|
|
|
|
public class PlayerJunkMVT : MonoBehaviour
|
|
{
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
var gradient = new Gradient();
|
|
|
|
// Blend color from red at 0% to blue at 100%
|
|
var colors = new GradientColorKey[2];
|
|
colors[0] = new GradientColorKey(Color.red, 0.0f);
|
|
colors[1] = new GradientColorKey(Color.green, 1.0f);
|
|
|
|
// Blend alpha from opaque at 0% to transparent at 100%
|
|
var alphas = new GradientAlphaKey[2];
|
|
alphas[0] = new GradientAlphaKey(1.0f, 0.0f);
|
|
alphas[1] = new GradientAlphaKey(1.0f, 0.0f);
|
|
|
|
gradient.SetKeys(colors, alphas);
|
|
|
|
// What's the color at the relative time 0.25 (25%) ?
|
|
Debug.Log(gradient.Evaluate(0.25f));
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
float SPEED = 10.0f;
|
|
float ROT = 100.0f;
|
|
if (Input.GetKey(KeyCode.UpArrow))
|
|
{
|
|
Debug.Log("avancer");
|
|
transform.Translate(Vector3.forward * Time.deltaTime * SPEED);
|
|
}
|
|
if (Input.GetKey(KeyCode.DownArrow))
|
|
{
|
|
Debug.Log("reculer");
|
|
transform.Translate(-Vector3.forward * Time.deltaTime * SPEED);
|
|
}
|
|
if (Input.GetKey(KeyCode.LeftArrow))
|
|
{
|
|
Debug.Log("tourner la tête à gauche");
|
|
transform.Rotate(0.0f, -ROT * Time.deltaTime, 0.0f, Space.Self);
|
|
}
|
|
if (Input.GetKey(KeyCode.RightArrow))
|
|
{
|
|
Debug.Log("tourner la tête à droite");
|
|
transform.Rotate(0.0f, ROT * Time.deltaTime, 0.0f, Space.Self);
|
|
}
|
|
}
|
|
}
|