as the title says im looking for a way to make a cube shaped object slowly rise up, then slam back down. i know the basics to make it move forward and back, bit thats about it
Well you weren’t too specific, so I’ll just give you a basic tutorial on transform.Translate, in C-sharp, since you also didn’t specify the language you want to use. This will still get you going.
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
float speed;
Vector3 direction;
float min;
float max;
float units = 2.0f;
void Start()
{
//Set max to CURRENT position on Y axis, and set min to current minus units (2.0 in this example).
max = transform.position.y;
min = transform.position.y - units;
//Set first direction to be down
direction = Vector3.down;
}
void Update()
{
//Change speed depending on direction of object translation.
if(direction == Vector3.down)
{
speed = 10.0f;
}
else if(direction == Vector3.up)
{
speed = 1.0f;
}
//Use transform.Translate to move the current direction and current speed.
transform.Translate(direction * speed * Time.deltaTime);
//Change direction if object has reached min or max position on the Y axis (up and down).
if(transform.position.y >= max)
{
direction = Vector3.down;
}
if(transform.position.y <= min)
{
direction = Vector3.up;
}
}
}
can i use this in vr.