Ok, I’m starting to get a better picture now thank you!
Now would I attach this script to my enemy prefab?
So that each instance of that prefab is subscribed to recalculate method?
Ok, I’m starting to get a better picture now thank you!
Now would I attach this script to my enemy prefab?
So that each instance of that prefab is subscribed to recalculate method?
No this should be part of pathfinder. As i said there is only example not real code.
Got it, I’ll play around with it and give it my best.
You’ve been a ton of help thank you for all of your help and answering my questions I really appreciate it!
BTW can you send me links to your projects you did on here? I would like to play them and see what you’ve done
I see where your enemy recalculate path. I think you should leave it as is.
I’m sorry I don’t understand.
You see where I’m calling RecalculatePath?
I don’t understand how to call this new class inside of pathfinder properly either.
This is going to take me a while to wrap my head around I don’t want to be a bother I’m sorry.
I’m gonna look up a video on youtube maybe I can find one on unity action.
Do you have any other project built on sharemygame.com though? I would really like to play your demos
This is the one I’m watching now I remember watching this months ago and never touching implementation. Have you heard of this pattern before?
Can you explain what exactly you want to do and what you dont like that is in your proj rn. Because I am may be giving you wrong advice.
This is very important and you will use it a lot.
Thank you I appreciate your support with this
In the project I am not happy with the BroadCast Message function it seems very limited in comparison to what you are showing me and what I’m seeing in this video. Broadcast Message is not working for me and I have played with the script execution order to fix it and nothing is working
In the project at this time I would like to get my existing enemies to listen to the new path being updated via tower placement on tile.
Ok then in tower script Add
using UnityEngine.Events;
public class Tower : Monobehaviour
....your fields.....
public static UnityAction onAnyNewTowerPlaced;
.......
void OnEnable()
{
your code....
onAnyNewTowerPlaced?.Invoke();
}
and in enemy move script
void Awake()
{
Tower.onAnyNewTowerPlaced += delegate {
RecalculatePath();
StopAllCoroutines();
StartCoroutine(FollowPath())};
// BUT now you want recalculate not from start node but from current node! So you should store current node and change RecalculatePath to accept current node. But if you already on current node you dont need to start path from current node so you start move from next node.
enemy = FindObjectOfType<Enemy>();
enemy = FindObjectOfType<Enemy>();
gridManager = FindObjectOfType<GridManager>();
pathFinder = FindObjectOfType<PathFinder>();
}
Thank you!
This is a pretty big challenge for me I’ll give it a go after I’ve watched the video and have a better understanding of dealing with delegates.
that top line of code in awake scares the crap out of me lol is “delegate” referring to the name I give to the delegate and then saying that RecalculatePath(); StopAllCoroutines(); and StartCoroutine(FollowPath()); are all subscribed to that delegate?
You can do this UnityAction newAction += delegate{ and here you can write bunch of methods or assign variable}; and this whole crap will be executed when you invoke newAction.
Daaaaaang that’s cool !! I understand better now thank you! Almost done with the video and taking notes as soon as I’m done iIll give all of this a go and let you know how it turns out.
Thank you
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.