Question by
Natti1965 · Jun 22, 2020 at 02:54 PM ·
instantiateclone
cant get my clone to move, help,,Trying to get my clone to move
using System.Collections; using System.Collections.Generic; using System.Numerics; using UnityEngine;
public class SpawnScript : MonoBehaviour { public Rigidbody2D enemy; float randY; UnityEngine.Vector3 whereToSpawn; public float spawnRate = 2f; float nextSpawn = 0.0f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Time.time > nextSpawn)
{
nextSpawn = Time.time + spawnRate;
Rigidbody2D clone;
randY = Random.Range(-3f, 7.5f);
whereToSpawn = new UnityEngine.Vector3(11, randY,-1);
clone = Instantiate(enemy, whereToSpawn, transform.rotation);
clone.velocity = transform.TransformDirection(UnityEngine.Vector3.forward * 10);
}
Comment