Question by
Norden1984 · Sep 06, 2017 at 06:22 AM ·
movementparentparent transform
How to move an object left and righ (looping) when it still move to left with it parent
I use this to make loop
using UnityEngine; using System.Collections;
public class BackAndForth : MonoBehaviour {
public float delta = 1.5f; // Amount to move left and right from the start point
public float speed = 2.0f;
private Vector3 startPos;
void Start () {
startPos = transform.position;
}
void Update () {
Vector3 v = startPos;
v.x += delta * Mathf.Sin (Time.time * speed);
transform.position = v;
}
}
but the game object not linked with its parent on x axis anymore any body can help
Comment