'Make lift go up?
So I found this lift script online, and the answer is probably so obvious and I feel stupid for not seeing this earlier, but right now this script makes the lift go down, how do I make it go up? I've tried rearranging the transform.positions in different x,y,z combinations but no luck. Thoughts?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Elevator3 : MonoBehaviour {
public int speed = 1;
private int i = 10;
bool keyPressed = false;
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.E))
{
keyPressed = true;
}
if (keyPressed == true)
{
startLift();
}
}
void startLift()
{
transform.position = Vector3.Lerp(transform.position,
new Vector3(transform.position.x, 10, transform.position.z),
Time.deltaTime * speed);
}
void stopLift()
{
keyPressed = false;
}
}
Solution 1:[1]
I know nothing about Unity but anyway... assuming Cartesian coordinates, have you tried increasing the 'y' coordinate in StartLift? Maybe something like
transform.position = Vector3.Lerp(transform.position,
new Vector3(transform.position.x, transform.position.y+10, transform.position.z),
Time.deltaTime * speed);
I quite like the thought you could also change the x and z coordinates and make the world's first 3 dimensional lift.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |