- Home /
lerp rotation on button press?
I really need your help guys. Im total beginner. Is there a script which does the same like this but with rotation instead of position?
using UnityEngine;
using System.Collections;
public class lerp : MonoBehaviour
{
private Vector3 newPosition;
void Awake ()
{
newPosition = transform.position;
}
void Update ()
{
PositionChanging ();
}
void PositionChanging ()
{
Vector3 positionA = new Vector3(-15037,24,23166);
Vector3 positionB = new Vector3(-15037,40,23166);
if (Input.GetKeyDown (KeyCode.Q))
newPosition = positionA;
if (Input.GetKeyDown (KeyCode.E))
newPosition = positionB;
transform.position = Vector3.Lerp (transform.position, newPosition, Time.deltaTime);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613201042im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Key input to rotate object 2 Answers
lerp rotation by key press -1 Answers
show texture on key down 0 Answers
How to Rotate Game Object in specific Angle repeatedly on Key Press? 1 Answer
Flip over an object (smooth transition) 3 Answers