"how to make point spawn random on screen after collected" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "how to make point spawn random on screen after collected" answered properly. Developers are finding an appropriate answer about how to make point spawn random on screen after collected related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like how to make point spawn random on screen after collected. Enter your desired code related query in the search bar and get every piece of information about C# code related question on how to make point spawn random on screen after collected.
how to make point spawn random on screen after collected
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Collect : MonoBehaviour
{
private Rigidbody2D rb;
//this goes on player as a script
[SerializeField]
private GameObject Point;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
SpawnPoint();
}
// Update is called once per frame
void Update()
{
}
private void FixedUpdate()
{
}
private void SpawnPoint()
{
bool pointSpawned = false;
while (!pointSpawned)
{
//replace the range with points on your camera, first is X cord second is Y cord
Vector3 pointPosition = new Vector3(Random.Range(-13f, 13f), Random.Range(-8f, 8f), 0f);
if ((pointPosition - transform.position).magnitude < 3)
{
continue;
}
else
{
Instantiate(Point, pointPosition, Quaternion.identity);
pointSpawned = true;
}
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
Destroy(collision.gameObject);
SpawnPoint();
}
}
All those coders who are working on the C# based application and are stuck on how to make point spawn random on screen after collected can get a collection of related answers to their query. Programmers need to enter their query on how to make point spawn random on screen after collected related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to make point spawn random on screen after collected for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of how to make point spawn random on screen after collected while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "how to make point spawn random on screen after collected". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to make point spawn random on screen after collected resolved professionally and stay updated to the latest C# updates.