- Home /
Multiple technical questions/Don't code to spec
Create Waypoint on mouseclick
So I have created 2 NavMeshAgent's to go to their own target. The Foe has a already placed target. But I want to be able to put out my Player agent's target mid game. So the way I want this is that I want to point the mouse to a specific area and click to place the prefab/navmesh target (within 10 meters from player) on the map. Code for NavMeshagent:
var target: Transform;
var mesh: NavMesh;
private var agent: NavMeshAgent;
function Start () {
agent = GetComponent.<NavMeshAgent>();
agent.SetDestination(target.position);
}
Code needed for target placement:
1. get mouse possition
2. place prefab/target
3. make agent go there
Please Help!
The way I read you question, you are asking for specific code to be written for you. That is not how this list works. We help you solve your problems so you can write your own code. The code to find a position in world space on a mouse click has been posted 1000's of times, as well as instantiating an object at a position. Please research these topics. If you get stuck ask back along with the code you are working on.
I understand completely, kinda asked for to much. But however, I never find any solution myself to any of these 1000's times... I must be rely bad at research. Can you please send me a link if it's ok :)
Follow this Question
Related Questions
How to make speed changed in js 1 Answer
Duplicating NavMesh Objects 0 Answers
I get NullReferenceException when I use raycasts 0 Answers
Script issues [js] 0 Answers
Unable to enable or disable NavMeshAgent through script? 0 Answers