简体   繁体   中英

Making an object Teleport back to start upon reaching a certain point (Unity 2D)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move : MonoBehaviour {

    public Transform tf;



    // Use this for initialization
    void Start () {
        
    }
    
    // Update is called once per frame
    void Update () {
        transform.Translate(0, -0.10F, 0 * Time.deltaTime);
    }

Hello, I am making a game in which the character gets hit by a car, I want the car to move down, then teleport back up in a loop, that way you need to avoid the cars. Thank you.

Your question is not very clear to me. But, if you just want the car to teleport then you can set the transform.position of the car to the position you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM