please help. everything works. but when player reaches the red sphere. i checked my animation and player is not going back to idle instead the animation is moving still between idle and walking
Didn't work for me, code was fine but the fing orb did nothing to make my char move. Really well explained however, shame to see there's not been anymore videos.
I have two problems. 1) I don't have a flat surface and the character never stops walking (ie. player velocity is never zero) and 2) player walks through obstacles. Do I have to add those objects to some layer to stop that?
Figured out how to make the player not walk through obstacles by adding them to "Not walkable" under Object ... and I put the player on a flat plane but it still never stops walking.
I had the same damn problem lol. I figured out what to do though: public float stopDistance = 1; add this after player.SetDestination: player.stoppingDistance = stopDistance;
I would guess that the issue lies in your animator controller, possibly the way you transition between the two animations? If not that, double check that there is no collision on the target destination sphere preventing the player from fully reaching the destination
For some reason my target destination object (sphere) wont appear where i click. it stays below the scene, and if i move it and click on it, my character walks to it. but i cant get it to change its transform. any help? my code is exactly the same :(
Seems like there is an issue with adjusting the transform of the sphere. Just to be safe post your code here so I can take a look, and double check that all variables are properly assigned.
@@mattwester9093 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public class CharacterControl : MonoBehaviour { public Camera cam; public NavMeshAgent player; public Animator playerAnimator; public GameObject targetDest;
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hitPoint; if(Physics.Raycast(ray, out hitPoint)) { targetDest.transform.position = hitPoint.point; player.SetDestination(hitPoint.point);
} }
if (player.velocity != Vector3.zero) { playerAnimator.SetBool("isWalking", true); } else if (player.velocity == Vector3.zero) { playerAnimator.SetBool("isWalking", false); } }
@@mattwester9093 its weird, because it almost works. Just the sphere doesnt move at all by itself. I have to move it in the game window, click on it, and she moves to it. but it wont spawn. i have all four variables assigned, camera, player (navmeshagent), player (animator), and Target Destination object. I even tried the code on the Unity website, and like two other videos and that didnt work either lol
I had the same issue. I think it depends on the walking animation if the velocity of the agent can drop to zero (and the animation goes back to idle). I used a float variable in the control script as a minimum distance threshold and it works fine now. [SerializeField] float minDistanceToTarget = 0.1f; // in Update() instead of checking the velocity: if (player.remainingDistance > minDistanceToTarget) { animator.SetBool("isWalking", true); } else { animator.SetBool("isWalking", false); }
Fantastic brother!! Please do more rpg style tutorials. Love it! Helped me a lot!!
Glad to hear it helped!
Exactly what i was looking for, how to make camera follow the character and input with touch instead of mouse.
thank you so much, im working on a point and click for my course and I couldnt figure this out thank you jesus christ i needed this
Great tutorial! Very understandable! Thank you so much!! Keep it up! ☺
Thank you for the video
please help. everything works. but when player reaches the red sphere. i checked my animation and player is not going back to idle instead the animation is moving still between idle and walking
Hi! Im new to game making and im following along this video. Did you try to set stopping distance to some value?
@@ElGabroVero yes. I ended the project as it couldn’t be fixed. But thanks for your response
@@micol04 Sorry to hear about that :( wish you luck for the future, man!
Great tutorial, thanks a lot!
Why does my character when approaching the destination run around it?
Didn't work for me, code was fine but the fing orb did nothing to make my char move.
Really well explained however, shame to see there's not been anymore videos.
deactivate the collider of the capsule that workt for me
How is the player rotating when you move? my character does not face the target
Hi! I had the same problem too! There is a variable to set sotpping distance! Try with 0.5 for example
The animation does not change from idle to walking when I move the character :(
actually my mistake, I had the wrong animator selected on the script component, its working for me now. Thx for the vid :)
hey could u make a tutorial with simple puzzles like ur game "tharn" pls i need it
Hello, why does the player continue to play the walking animation for half a second when reaching the destination?
hello, do you have a fix for this?
I have two problems. 1) I don't have a flat surface and the character never stops walking (ie. player velocity is never zero) and 2) player walks through obstacles. Do I have to add those objects to some layer to stop that?
Figured out how to make the player not walk through obstacles by adding them to "Not walkable" under Object ... and I put the player on a flat plane but it still never stops walking.
I had the same damn problem lol. I figured out what to do though:
public float stopDistance = 1;
add this after player.SetDestination:
player.stoppingDistance = stopDistance;
@@_D3adB0y_ thank you so much
1:52 Bake is grayed out for me.
hello from french.
thank you for tutorial, he help me ^^
like.
since 7 months, no video. are you ok ? you are busy ?
great! subbed
PLEASE someone help. when my player gets on the target destination sphere, it begins to loop between walking and stopping animation. anyone knows why?
I would guess that the issue lies in your animator controller, possibly the way you transition between the two animations? If not that, double check that there is no collision on the target destination sphere preventing the player from fully reaching the destination
@@mattwester9093 i have same problem I even completely removed the Sphere
Not sure if you ever fixed this issue, but I would make sure on your Animator that the "Apply Root Motion" is not check marked.
@@cademarsh5097 I unchecked it but abandoned the project anyway for another. Thanks
Any idea as to why the player won't move? I'm kinda goosed atm. I'm no programmer or Unity fanatic
hey buddy
Ah. I see we meet again@@emilythebaptist
@@LeetardPlays Just got it to work! hope it goes well for u
@@emilythebaptistI disliked this comment
For some reason my target destination object (sphere) wont appear where i click. it stays below the scene, and if i move it and click on it, my character walks to it. but i cant get it to change its transform. any help? my code is exactly the same :(
Seems like there is an issue with adjusting the transform of the sphere. Just to be safe post your code here so I can take a look, and double check that all variables are properly assigned.
@@mattwester9093 using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class CharacterControl : MonoBehaviour
{
public Camera cam;
public NavMeshAgent player;
public Animator playerAnimator;
public GameObject targetDest;
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hitPoint;
if(Physics.Raycast(ray, out hitPoint))
{
targetDest.transform.position = hitPoint.point;
player.SetDestination(hitPoint.point);
}
}
if (player.velocity != Vector3.zero)
{
playerAnimator.SetBool("isWalking", true);
}
else if (player.velocity == Vector3.zero)
{
playerAnimator.SetBool("isWalking", false);
}
}
}
@@mattwester9093 its weird, because it almost works. Just the sphere doesnt move at all by itself. I have to move it in the game window, click on it, and she moves to it. but it wont spawn. i have all four variables assigned, camera, player (navmeshagent), player (animator), and Target Destination object. I even tried the code on the Unity website, and like two other videos and that didnt work either lol
Any Reasons Why when the character reach his destination it will start walking in circles around the sphere?
I'm guessing the sphere has a collider that stops the character from actually reaching the destination, so he walks circles around
I had the same issue. I think it depends on the walking animation if the velocity of the agent can drop to zero (and the animation goes back to idle). I used a float variable in the control script as a minimum distance threshold and it works fine now.
[SerializeField] float minDistanceToTarget = 0.1f;
// in Update() instead of checking the velocity:
if (player.remainingDistance > minDistanceToTarget) { animator.SetBool("isWalking", true); }
else { animator.SetBool("isWalking", false); }
Thanks!!!!!!!!!!!
Hi matt I cant open your website
Hey sorry about that. I'm tracking the issue, but unfortunately I'm getting on a plane and won't be able to fix it until later today
Thank you for your patience, the issue should be fixed now, but please allow up to 48 hours for the servers to apply my solution:)
tharn game???
script doesn't work anymore, don't bother
As far as I know this script still works fine. Could you post any errors you have?
thnxxxxxxxx