Created
January 28, 2021 16:38
-
-
Save TheCuttlefish/6c5ada70399ce9fc2ad7532cad14ef43 to your computer and use it in GitHub Desktop.
Bar functionality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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