Skip to content

Instantly share code, notes, and snippets.

@TheCuttlefish
Created January 28, 2021 16:38
Show Gist options
  • Save TheCuttlefish/6c5ada70399ce9fc2ad7532cad14ef43 to your computer and use it in GitHub Desktop.
Save TheCuttlefish/6c5ada70399ce9fc2ad7532cad14ef43 to your computer and use it in GitHub Desktop.
Bar functionality
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bar : MonoBehaviour
{
public float fr = 1;
float climbValue;
float climbItensity = 1;
public Gradient barColour;
public GameObject bar;
// Update is called once per frame
void Update()
{
climbValue = Mathf.Abs(Mathf.Cos(Time.time * fr));
transform.localScale = new Vector3(1, climbValue, 1);
bar.GetComponent<SpriteRenderer>().color = barColour.Evaluate(climbValue);
if (Input.GetKeyDown(KeyCode.Space))
{
//pass into velocity rb.velocty = new vec2 (pos.x ,climbValue * climbItensity);
print(climbValue);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment