Quick and easy question; what easy line of code can I use on lines 79 and 110 of the document below so the player would need to press “E” in a certain range of the npc rather than when the player enters a collider? thanks in advance!
You should post your code within the forum within code tags. People generally don’t want to download your files to their computer to help with a simple code question.
I’m not sure if I did this correct bc it has no effect, must be because of my limited knowledge with C#. I prob could fix this myself if I knew how to script. Another point to note is that I first replaced void OnTriggerEnter(Collider other) { with private void Update1(){ and it said the (other.) of if (other.gameObject.tag == “Tuto”) { does not work unless I delete it
MonoBehaviour.Update() is Unity method which is called every frame, you shoud check player’s input in there. So if you will name the method Update1() it will not work.
When you add code, it’s best when you post it using code tags.
The methods you’ve renamed have a special name that’s used by the engine to call them. Just like Start, Update and many more.
The variable ‘other’ is no longer known/accessible in your renamed method, because you’ve not only changed the method’s name, but also removed the parameter list - which was ‘Collider other’ before, hence the name is not known.
I’d recommend to take a step back and work through some of the official tutorials first.
The problem with the Update() needing to be Update1() is because when I tried to copy what u had, there already was void Update() so they cant both be named the same. Unless I leave out the private void update and go straight to “if (isInRange && Input.GetKeyDown(KeyCode.E))” but that doesnt work either. I clearly have no knowledge of coding so if its not close to just copy and paste I seem to mess it up. Thanks for all your help though!
Thanks, that clears up alot! only problem is I do not have time to go through tutorials first because my deadlines are catching up, which led me to here.
the problem here is that it says the script name, DialogueManager, already defines a member called onTriggerEnter. I realize this is because i have it both in the bool and in the void update. the problem is I do not know what to change it to bc deleting it caused more problems
You don’t have to replace the content of your Update or OnTriggerEnter methods, just append your new code after the existing code. But it must be inside these special methods for everything to work properly.
Yeah well you’ll just be having problems forever until you do. So after your deadlines, you should go through tutorials or you’ll keep asking forum and getting it wrong. There’s no shortcut for understanding it properly here.