It's probably too late to give advice, but for those who stumble upon this video, I recommend turning on DESTROY in the effect tab in "Stop actions" so that the effects are removed
Good tutorial, had a couple problems with implementing it in my project, here is how i fixed if anyone has similar issue: Had an issue with Input.mousePosition in PlayerController script not being read, I had to go into player settings (Edit > project settings > player) and find the Active Input Handling dropdown and select "both". This fixed my errors but player wouldn't move on mouse click, as I didn't have any clickable layers set so, for temporary testing I just went to the inspector of the character and changed the clickable layers to "everything".
I don't suppose you'll check this and say how you set clickable layers to everything. Is this option supposed to be under the NavMeshSurface in the inspector?
@Marzipanilla it should be on a dropdown on one of the objects in the inspector, maybe on nav mesh agent if i remember correctly(?) not at my pc rn so i cant check, perhaps search it on google if you cant find it
if you face the code problem where your player reset rotation on arrival you can use this in void FaceTarget() function instead = void FaceTarget() { if (agent.velocity != Vector3.zero) { Vector3 direction = (agent.destination - transform.position).normalized; Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z)); transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * lookRotationSpeed); } }
If anyone is having problems with Orthographic Camera, e.g. character is not moving on clicked, check out your values for Camera Clipping Planes. I've managed to solve by setting Near to 0.01 and Far to 1000. In my case, negative values for Near Clipping Plane caused the issue. Orthographic Size has been set to 15, btw.
Thanks for the tutorial. How would you go about expanding this to continually move towards the mouse if you hold the button down? Similar to in Diablo.
If you're using the new Input System like this video, check out this approach. stackoverflow.com/questions/59837392/how-to-repeat-function-while-button-is-held-down-new-unity-input-system. Otherwise, if you're using the old Input System add this to update... if(Input.GetMouseButton(1)) { ClickToMove(); }
I can help if you still have the problem. But diablo need the original old input system that i also use :) I have a ready script and you just need to adjust some things in navmesh agent. simple
Hi I have a problem where the character does reach the destination, but lags behind and teleports as the animation happens. It does arrive yes but it does that where it is buggy and laggy. It does work perfectly though when clicking the area and it arriving there.
my player controller somehow stopped working! it was all good , i cant figure out what happened,i even created a new project watch the tutorial few times to make sure i get everything right, it wont even work in the new project too! how come it was working few hours ago and wont work anymore , what is wrong with unity ? please help me
Hola, estoy desarrollando un videojuego estilo RPG y me he encontrado con el problema de los pisos superiores e inferiores, al buscar diferentes formas de fade, transparect, etc. no encuentro la solución deseada, alguien ofrece el servicio para que me ayude a solucionar mi problema?
I'm getting error on input.Main.Move.performed += ctx => ClickToMove(); "Severity Code Description Project File Line Suppression State Error CS1061 'CustomActions.MainActions' does not contain a definition for 'Move' and no accessible extension method 'Move' accepting a first argument of type 'CustomActions.MainActions' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp
make sure you save the changes made to the CustomActions file (in the Input Actions editor window). you can either just click the Save Asset button, or check the Auto Save box.
After I did the code, I noticed that when the player object gets to the click position, say he is facing right, once he arrives to the spot I cliked he faces left (or to the front i guess), anyway to fix this.
I've run into this error when creating this system too. You may have made a mistake within the FaceTarget(). Double check it or just copy it from the github link!
Sorry, I realized that this is not an issue, but just how the code works. edit: Going to just edit this instead of putting a new comment. I figure out how to make the character stay in the same direction you move. Put the variable Vector3 direction at the top with the movement variables. Move the "direction = (agent.destination - transform.position).normalized;" to the ClicktoMove function. That way it will keep the direction until the mouse is clicked again.
Another solution I just found is to put 'if(lookRotation.x != 0 || lookRotation.y != 0)' inside FaceTarget function, right above transform.rotation command
I 'm so sick of it ! again I did everything as in the video and again it does not work ! your build is also not working as usual for everyone on TH-cam
if anyone is having an issue with the character's FaceTarget snapping after they stop moving. simply check to see if the velocity is zero. and if it is just return. void FaceTarget() { if (agent.velocity == Vector3.zero) return; Vector3 direction = (agent.destination - transform.position).normalized; Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z)); transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * lookRotationSpeed); }
It's probably too late to give advice, but for those who stumble upon this video, I recommend turning on DESTROY in the effect tab in "Stop actions" so that the effects are removed
Legend
Good tutorial, had a couple problems with implementing it in my project, here is how i fixed if anyone has similar issue:
Had an issue with Input.mousePosition in PlayerController script not being read, I had to go into player settings (Edit > project settings > player) and find the Active Input Handling dropdown and select "both".
This fixed my errors but player wouldn't move on mouse click, as I didn't have any clickable layers set so, for temporary testing I just went to the inspector of the character and changed the clickable layers to "everything".
omg thank you so much Mogg! 😃
Life SAVER!
@@wernerschreuder9800 good luck on your project
I don't suppose you'll check this and say how you set clickable layers to everything. Is this option supposed to be under the NavMeshSurface in the inspector?
@Marzipanilla it should be on a dropdown on one of the objects in the inspector, maybe on nav mesh agent if i remember correctly(?) not at my pc rn so i cant check, perhaps search it on google if you cant find it
at first it wasn't working but then i realized that i had to select the default layer for the player controller script, Thanks !
I just spent 20 min trying to figure out why it doesn't work. You saved me 😅
if you face the code problem where your player reset rotation on arrival you can use this in void FaceTarget() function instead =
void FaceTarget()
{
if (agent.velocity != Vector3.zero)
{
Vector3 direction = (agent.destination - transform.position).normalized;
Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z));
transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * lookRotationSpeed);
}
}
Perfect
If anyone is having problems with Orthographic Camera, e.g. character is not moving on clicked, check out your values for Camera Clipping Planes. I've managed to solve by setting Near to 0.01 and Far to 1000. In my case, negative values for Near Clipping Plane caused the issue. Orthographic Size has been set to 15, btw.
Ur amazing its a crime how underated dis is
Great video! Thanks a lot for the great explanation, that's what I was looking for!
Easy, clean and very easy to follow!! Subscribed :D
Thanks for the tutorial. How would you go about expanding this to continually move towards the mouse if you hold the button down? Similar to in Diablo.
If you're using the new Input System like this video, check out this approach. stackoverflow.com/questions/59837392/how-to-repeat-function-while-button-is-held-down-new-unity-input-system.
Otherwise, if you're using the old Input System add this to update...
if(Input.GetMouseButton(1))
{ ClickToMove(); }
@@Its_Pogle Thanks, I'll give it a go.
I can help if you still have the problem. But diablo need the original old input system that i also use :) I have a ready script and you just need to adjust some things in navmesh agent. simple
Hi I have a problem where the character does reach the destination, but lags behind and teleports as the animation happens. It does arrive yes but it does that where it is buggy and laggy. It does work perfectly though when clicking the area and it arriving there.
i got stuck with the circle mat render
Error with your Circle material, seems to be a particle shader error. Cant find the shader you are using.
i cant figure any thing out would u help me pog?
If Input Actions does not appear on your create list, return to package manager and download Input System from Unity Registry.
my player controller somehow stopped working! it was all good , i cant figure out what happened,i even created a new project watch the tutorial few times to make sure i get everything right, it wont even work in the new project too! how come it was working few hours ago and wont work anymore , what is wrong with unity ? please help me
same! any help?
no matter what I click or do ClickToMove(); never gets called??
hey man can u make more of this series please
Nice work👍🏻
ive used a character from the pack that you used but i cant find the avarat for it for the animation controller @PogleDev
Why am I not seeing navmeshsurface? I am getting an error on the environment game object. saying there is a missing script.
You'll have to download the 'com.unity.ai.navigation' package to see the script.
Hola, estoy desarrollando un videojuego estilo RPG y me he encontrado con el problema de los pisos superiores e inferiores, al buscar diferentes formas de fade, transparect, etc. no encuentro la solución deseada, alguien ofrece el servicio para que me ayude a solucionar mi problema?
when I start the game the camera goes underground, I don't know how to fix it.
Make sure the offset Vector3 reference on the Camera Controller is given values (6 on Y and -5 on the Z)
@@Its_Pogle I got it working
I'm getting error on input.Main.Move.performed += ctx => ClickToMove();
"Severity Code Description Project File Line Suppression State
Error CS1061 'CustomActions.MainActions' does not contain a definition for 'Move' and no accessible extension method 'Move' accepting a first argument of type 'CustomActions.MainActions' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp
make sure you save the changes made to the CustomActions file (in the Input Actions editor window). you can either just click the Save Asset button, or check the Auto Save box.
After I did the code, I noticed that when the player object gets to the click position, say he is facing right, once he arrives to the spot I cliked he faces left (or to the front i guess), anyway to fix this.
I've run into this error when creating this system too. You may have made a mistake within the FaceTarget(). Double check it or just copy it from the github link!
Sorry, I realized that this is not an issue, but just how the code works.
edit: Going to just edit this instead of putting a new comment. I figure out how to make the character stay in the same direction you move. Put the variable Vector3 direction at the top with the movement variables. Move the "direction = (agent.destination - transform.position).normalized;" to the ClicktoMove function. That way it will keep the direction until the mouse is clicked again.
@@issykidding Just change FaceTarget call from Update to ClickToMove and crank up LookRotationSpeed for 80 times
Another solution I just found is to put 'if(lookRotation.x != 0 || lookRotation.y != 0)' inside FaceTarget function, right above transform.rotation command
@@issykidding genius, thanks
This is cool
Very Little explanation on why you are writing the methods and how they actually work. you don't have to speed through it either.
Add remaining distance checking in FaceTarget so it does not rotate like an idiot in the end :P
mirrored ever file, and every keystroke - still no luck - also went through all comments here - looks like this will not work on Unity 6 and newer
I cant find AI Navigation package kinda unlucky gg
Its built in, go Window > Ai > Navigation
I 'm so sick of it ! again I did everything as in the video and again it does not work ! your build is also not working as usual for everyone on TH-cam
you go through these steps way, way too fast. and the fast forwarding is really frustrating.
if anyone is having an issue with the character's FaceTarget snapping after they stop moving. simply check to see if the velocity is zero. and if it is just return.
void FaceTarget()
{
if (agent.velocity == Vector3.zero) return;
Vector3 direction = (agent.destination - transform.position).normalized;
Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z));
transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * lookRotationSpeed);
}