- Home /
Smoothly translating an object down upon Raycast.
My code is set up so that my lake does something upon being seen by the player.
However, I've attempted to use transforming to do this, due to the fact that animation is quite painful to do and sync up and trigger with a script.
My question is, how do I, using translation, smoothly translate my lake from Y(23.92), to Y(2.74), upon being looked at by the player?
using UnityEngine;
using System.Collections;
public class WaterManager : MonoBehaviour {
bool WaterIsHigh = true;
float waterTimer = 0.0f;
public float waterStopTime = 5.0f;
GameObject currentWater;
// Use this for initialization
void Start () {
waterTimer = 0.0f;
}
void WaterCheck (){
if(!WaterIsHigh){
//Where the transformation code goes!
}
}
// Update is called once per frame
void Update () {
if (WaterIsHigh){
waterTimer += Time.deltaTime;
}
if (waterTimer > waterStopTime){
waterTimer = 0.0f;
WaterIsHigh = false;
}
}
}
Here is my code so far.
Thank you for any help!
Answer by LMan · Sep 29, 2015 at 07:57 PM
Have you tried Vector3.Lerp?
Another option might be Transform.Translate.
Or, you could use an animation to move the object.
Your answer
Follow this Question
Related Questions
Translation of an Object 0 Answers
Network.Instantiate Spanws player 2 wrong way 2 Answers
Translate Point By Vector3 And Angle 1 Answer
Move child objects in the opposite direction of parent object 0 Answers
How to translate text 0 Answers