Home > Software design >  A spawner that spawns in a certain area
A spawner that spawns in a certain area

Time:02-22

I have been working on a game and my brain is dead I need help does anyone have a good base script to spawn objects at a random interval something like a metor game where metor's are spawned at top like does airplane shooting dodger. (The meaning of insanity is doing something over and over again and expecting a different outcome.)

CodePudding user response:

The code still doesn't work are there any errors?

using System.Collections;

using System.Collections.Generic; using UnityEngine;

public class RainSpawn : MonoBehaviour { public GameObject myPrefab;

 public float timeBetweenSpawn;

void update(){ timeBetweenSpawn = 5 - Time.deltaTime; Instantiate(myPrefab, transform.position Random.insideUnitSphere * 5, Quaternion.identity); }

}

CodePudding user response:

enter image description here

You can try to write a plane script, this script controls the movement of the plane, when you press the left mouse button to shoot a bullet, there will be a sound effect when the bullet is fired. The parameter of the GameObject of the bullet is implemented in the preset, because there is no bullet in the scene at the beginning, and the player presses the left mouse button to have an instance of the bullet. The Update and FixedUpdate functions are used here. Several update functions distinguish Update. The number of frames called each frame is related to the current platform and is affected by device performance; FixedUpdate is called at fixed time intervals; LateUpdate is called every frame, but it is called after Update is executed; in general, it is called The frequency and sequence are different. Mathf.Clamp function, the parameter is a floating point number, it is a static function that limits the value, Mathf.Clamp (value min max) value is between min and max, it returns value, if the value is too small, it returns min, and if the value is too large, it returns max . This is used to limit the movement range of the aircraft. I am also looking for information and hope it can help you.

  • Related