I want to add a circular motion to that sphere but everytime i press play the sphere goes in another direction. What i wrong?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LightMotion : MonoBehaviour
{
float timeCounter = 0f;
// Start is called before the first frame update
void Start()
{
speed = 5f;
width = 4f;
height = 5f;
}
// Update is called once per frame
void Update()
{
timeCounter += Time.deltaTime*speed;
float x = Mathf.Cos(timeCounter)*width;
float y = Mathf.Sin(timeCounter)*height;
float z = transform.position.z;
gameObject.transform.position = new Vector3 (x, y, z);
}
}