Question by
JackBlizzard · Dec 18, 2021 at 05:11 AM ·
codepage
Trying to smooth out my crouch and prone functions
public class FPSCrouch : MonoBehaviour
{
[SerializeField] float crouchHeight;
[SerializeField] float lyingHeight;
[SerializeField] float normalHeight;
void Start()
{
}
// Update is called once per frame
void Update()
{
Vector3 newScale = new Vector3(transform.localScale.x, normalHeight, transform.localScale.z);
if (Input.GetKey(KeyCode.C))
{
newScale.y = crouchHeight;
}
else if (Input.GetKey(KeyCode.Z))
{
newScale.y = lyingHeight;
}
transform.localScale = newScale;
}
}
If anyone can help me, I'd appreciate it
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613050709im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Update and Get PlayerPrefs during runtime? 0 Answers
Reversing the process 0 Answers
My Raycast won't work at all ?? (C# Windows) 1 Answer
hi, please help with camera control on android phone 0 Answers