No overload for method.
Assets/Scripts/Indingo_Lava_Burst_Glitch_Fixed.cs(26,3): error CS1501: No overload for method ifIndingoCollidesWithEnemy’ takes
0′ arguments
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Indingo_Lava_Burst_Glitch_Fixed : MonoBehaviour {
private Indingo_Lava_Burst_Collider_Detecter_Attach_On_Enemies disableLavaBurst01;
private Indingo_Lava_Burst_Activator_Deactivator_Attach_On_Indingo disableLavaBurst02;
// Use this for initialization
void Start () {
disableLavaBurst01 = GetComponent<Indingo_Lava_Burst_Collider_Detecter_Attach_On_Enemies>();
disableLavaBurst02 = GetComponent<Indingo_Lava_Burst_Activator_Deactivator_Attach_On_Indingo>();
disableLavaBurst01.enabled = false;
disableLavaBurst02.enabled = false;
}
// Update is called once per frame
void FixedUpdate () {
ifIndingoCollidesWithEnemy ();
}
private void ifIndingoCollidesWithEnemy(Collision2D collision)
{
if (collision.gameObject.tag == "Enemy")
{
disableLavaBurst01.enabled = true;
disableLavaBurst02.enabled = true;
}
else
{
disableLavaBurst01.enabled = false;
disableLavaBurst02.enabled = false;
}
}
}
Answer by MacDx · Sep 10, 2017 at 12:45 AM
You are forgetting to pass a parameter when calling your method.
void FixedUpdate () {
ifIndingoCollidesWithEnemy (PARAMETER MISSING HERE);
}
@$$anonymous$$acDx Sorry, I'm a noob at Unity. But what parameter do I use?
Ok. I see that you are calling that function to detect if there was a collision between Indigo and an Enemy, however the way you have it set up right now will never detect if such collision happened. What you should do is use the Unity's callback method for monobehaviours OnCollisionEnter or OnCollisionEnter2D. Since in your method ifIndigoCollidesWithEnemy you have a Collision2D type parameter I'll assume your game is 2D and you only want to handle 2D collisions. So, to detect collision between your gameObjects with 2D colliders you need to include this method in your code ins$$anonymous$$d of the method you are using right now, and you don't need to call it in your fixed update nor in anywhere else, unity will call the method automatically for you when a collision happens.
void OnCollisionEnter2D(Collision2D coll) {
if (coll.gameObject.tag == "Enemy")
{
disableLavaBurst01.enabled = true;
disableLavaBurst02.enabled = true;
}
else
{
disableLavaBurst01.enabled = false;
disableLavaBurst02.enabled = false;
}
}
So to sum up. Don't use ifIndigoCollidesWithEnemy, get rid of it and replace it with the code I posted above, and never call this yourself.
@$$anonymous$$acDx | NullReferenceException: Object reference not set to an instance of an object Indingo_Lava_Burst_Glitch_Fixed.Start () (at Assets/Scripts/Indingo_Lava_Burst_Glitch_Fixed.cs:18)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Indingo_Lava_Burst_Glitch_Fixed : $$anonymous$$onoBehaviour {
private Indingo_Lava_Burst_Collider_Detecter_Attach_On_Enemies disableLavaBurst01;
private Indingo_Lava_Burst_Activator_Deactivator_Attach_On_Indingo disableLavaBurst02;
// Use this for initialization
void Start () {
disableLavaBurst01 = GetComponent<Indingo_Lava_Burst_Collider_Detecter_Attach_On_Enemies>();
disableLavaBurst02 = GetComponent<Indingo_Lava_Burst_Activator_Deactivator_Attach_On_Indingo>();
disableLavaBurst01.enabled = false;
disableLavaBurst02.enabled = false;
}
// Update is called once per frame
void FixedUpdate () {
}
void OnCollisionEnter2D(Collision2D coll) {
if (coll.gameObject.tag == "Enemy")
{
disableLavaBurst01.enabled = true;
disableLavaBurst02.enabled = true;
Debug.Log ("Indingo Collided With Enemy");
}
else
{
disableLavaBurst01.enabled = false;
disableLavaBurst02.enabled = false;
Debug.Log ("Indingo Did Not Collided With Enemy");
}
}
}
This line is the problem:
disableLavaBurst01 = GetComponent<Indingo_Lava_Burst_Collider_Detecter_Attach_On_Enemies>();
It is returning null which means it didn't find the component. Are you completely sure that you have an Indingo_LavaBurst_Collider_Detecter_Attach_On_Enemies script attached to the same game object your Indingo_Lava_Burst_Glitch_Fixed script is attached to?
Your answer
Follow this Question
Related Questions
Help! Values from previous Serialized List<> shows up again after a while using Coroutine 0 Answers
How to get the object to move only when I click on it and not just anywhere else? 1 Answer
GameObject not colliding properly with a collider! 3 Answers
How to Trigger/collision only once time per gameobject hit's? 0 Answers