Hey guys What i try to do is to spawn objects according to spawn variable p, however i get those errors, any help would be much appreciated. Here are the codes and error codes right after them :
using UnityEngine;
using System.Collections;
public class PatternCreator : MonoBehaviour {
public Transform prefab;
public float myTimer = 1.0f;
void Start()
{
}
// Update is called once per frame
void Update ()
{
if (myTimer > 0) {
myTimer -= Time.deltaTime;
}
if (myTimer <= 0) {
Spawn ();
float n = Random.Range (40.0F,50.0F); // bu deger test amaçlı sonra değiştir.
myTimer = n;
int p = Random.Range (1,2); // pattern numarası
}
}
void Spawn (int p)
{
if (p= 1) {
float x2 = Random.Range (0.0F, 360.0F);
float y2 = Random.Range (0.0F, 360.0F);
float z2 = Random.Range (0.0F, 360.0F);
Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
}
if (p= 2) {
float x2 = Random.Range (0.0F, 360.0F);
float y2 = Random.Range (0.0F, 360.0F);
float z2 = Random.Range (0.0F, 360.0F);
Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
}
}}
Assets/Scripts/PatternCreator.cs(27,29): warning CS0219: The variable `p' is assigned but its value is never used
Assets/Scripts/PatternCreator.cs(23,25): error CS1501: No overload for method `Spawn' takes `0' arguments
Assets/Scripts/PatternCreator.cs(36,17): error CS0029: Cannot implicitly convert type `int' to `bool'
Assets/Scripts/PatternCreator.cs(42,17): error CS0029: Cannot implicitly convert type `int' to `bool'