#Protected Override Void Function Won't Call After Adding Void Update Loop
1 messages · Page 1 of 1 (latest)
It's hard to answer a programming question without code
Resolving a bug is almost impossible when the question doesn't include any of the buggy code. In order to help fix the problem, answerers are going to have to see what the code is.
Source: https://idownvotedbecau.se/nocode
Please isolate the problematic code and send it as a codeblock. If you don't know how to send a codeblock, type []cb
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class basicTower : Tower
{
public Transform Pivot;
public Transform Barrel;
public GameObject Bullet;
private void Update()
{
if (towerMenu != null)
{
if (shopManagerScript != null)
{
newCost = shopManagerScript.basicTowerCost + 1;
}
towerMenu.upgradeCost = newCost;
}
if (upgradeTier == 1 && alrUpgraded == false)
{
Debug.Log("TIER 1 Upgrade");
alrUpgraded = true;
}
if (upgradeTier == 2 && alrUpgraded == false)
{
Debug.Log("TIER 2 Upgrade");
alrUpgraded = true;
}
if (upgradeTier == 3 && alrUpgraded == false)
{
Debug.Log("TIER 3 Upgrade");
alrUpgraded = true;
}
if (upgradeTier == 4 && alrUpgraded == false)
{
Debug.Log("TIER 4 Upgrade");
alrUpgraded = true;
}
if (upgradeTier == 5 && alrUpgraded == false)
{
Debug.Log("TIER 5 Upgrade");
alrUpgraded = true;
}
}
private void FixedUpdate()
{
if (towerMenu != null)
{
shopManagerScript = GameObject.Find("Shop_Manager").GetComponent<shopManager>();
if (towerMenu.upgrade && upgradeTier < upgradeLevels)
{
towerMenu.upgradeCost = newCost;
//Debug.Log("Upgrade");
if (moneyManager.Money.currentPlayerMoney >= newCost)
{
upgradeTier++;
moneyManager.Money.currentPlayerMoney = moneyManager.Money.currentPlayerMoney - newCost;
}
alrUpgraded = false;
//Debug.Log(upgradeTier);
towerMenu.upgrade = false;
}
}
}
protected override void Shoot() //not activating but why?
{
base.Shoot();
GameObject New_Bullet = Instantiate(Bullet,Barrel.position,Pivot.rotation);
}
}
sorry
That's not a codeblock
Use codeblocks to send code in a message!
To make a codeblock, surround your code with ```
To use C# syntax highlighting add cs after the three back ticks like so:
```cs
// your code here
```
To send lengthy code, paste it into https://paste.myst.rs/ and send the link of the paste into chat.
{
base.Shoot();
GameObject New_Bullet = Instantiate(Bullet,Barrel.position,Pivot.rotation);
}```
Where are you calling this method
That's not calling it
it calls normally when i run the script
because the script it derives from automatically calls it
Where
Are you sure the if statement is executing?
it executes when i remove the fixed update loop in the problematic script
Well if Shoot is not being called, there are four possibilities
- This behaviour isn't on any object
- The object is disabled (ergo
Updatewill not run) Next_Time_To_Shootis not low enough, meaningTime.timewill never be greater than or equal to itCurrent_Targetis null