Hi,
I bought AC a few days ago. I'm still trying to wrap my head around it. No need for a complex answer just hope you could point me in the right direction here.
I'm trying to replace the double click running with a teleporting.I've put a script on the player and add an double click event. And i've also found a way to teleport the player.
Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
KickStarter.player.transform.position = new Vector3(pos.x, pos.y, 0);
I want to run this code only:1. If the point is inside of the NavMesh
2. If mouse is not hovering a hotspot
And finally i want to align the character in the right direction. I've found this line of code:
KickStarter.player.SetLookDirection();
And i suppose the character will then face the point? Can i rather set the direction itself? Up / Down or 0 / 180 in degrees.
Thanks for help
Comments
Vector3 worldSpaceNavPoint = KickStarter.playerMovement.ClickPoint (KickStarter.playerInput.GetMousePosition (), true);
if (worldSpaceNavPoint != Vector3.zero)
{
KickStarter.player.Teleport (worldSpaceNavPoint);
}
You should also make sure, to avoid conflict, that the Settings Manager's Double-click movement field is set to Disabled.
by the angle i mean that the character should be aligned to direction that was teleported. From left to right = align to the right.
The SetRotation function is exactly what i need except why is the angle shifted?
This is the angle code:
Any idea how to simply shift the angle?
Teleport:
If a normal click is used outside of the NavMesh the character still goes to a new position within the NavMesh. Can i somehow use this destination point for the doubclick as well?
I'm trying to work with the scripting guide. There's so many things tho, it's kinda hard to orientate in that. But i hope that's just a matter of time.
Shifted by 90°. Those are the angles the script i've posted returns. Based on that i thought that right direction is 0° by default.
Thanks for the info. Very appreciated.
Edit: So I've managed to get the correct angle. Character gets teleported and aligned to the correct direction. But after that it gets overwriten and the character turn again by some built in system.
( Character in the back of the screen facing UP - teleported to the foreground and aligned to face DOWN - and after that turns left - or somewhere )
Can i somehow turn off this turning feature?
Video example:
https://youtu.be/327p4lK7KSg
Inside the NavMesh, teleporting not directly (first attemp) but on some later attempt causes the character to teleport and then walk away somewhere. I've put the Halt() function you mentioned inside without resolving the issue.
I didn't use the Quaternion because it doesn't return the angle i want. On the y-axis it makes the character turn to left or right. I suppose i don't undestand the value it returns. I want to be able to align to all directions based on the angle between the two points. ( As in the video below )
Code from the screenshot: http://pasteall.org/992542
Based on the Gizmos mode i now have my guess what is happening there.
It seems to be overwritten by the code in the PlayerMovement's PointControlPlayer function you mentioned before. Because the character walks exactly to the position where the character is sent if i click (normal click) outside of the NavMesh.
Only the final point from the PointControlPlayer function is different than the one from the screenshot / pasteall for the double click.
The Halt function doesn't stop the character from walking in the script though.
Video: https://youtu.be/sNIu-rEa6_M