I managed to get the game object to loop up and down, but I need it to constantly go left and anything I try fails.
(I tried using velocity)
The code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ysaucermove : MonoBehaviour {
public float amp = 0.75f;
public float freq = 1f;
// Position Storage Variables
Vector3 posOffset = new Vector3 ();
Vector3 tempPos = new Vector3 ();
// Use this for initialization
void Start () {
posOffset = transform.position;
}
// Update is called once per frame
void Update () {
tempPos = posOffset;
tempPos.y += Mathf.Sin (Time.fixedTime * Mathf.PI * freq) * amp;
transform.position = tempPos;
}
}
Velocity isn’t working for you probably because you are explicitly setting the transform.position to tempPos every frame. Since you never change the x value of tempPos. Your object’s x is going right back to the beginning every frame.