Sorry for asking so many questions.
I've introduced a compass asset (Northstar navigator).
This asset needs to set a prefab that will serve as the reference position.
Normally, that reference prefab would be the player,
but in ORK, the player spawns after the start,
so it's not possible to set it in advance for the compass asset.
I'm thinking of a few ways,
but are these possible in ORK?
Or is there any other good way?
- Have an object come to the same coordinates as the player after the start and follow the player.
- Have the player who spawns after the start be displayed in the hierarchy window in advance.
Create the Navigation HUD through hierarchy context menu, Makinom->HUD->Navigation Bar. You need the navigation bar which is like the compass itself and then the Nav Point prefabs for like N/S/E/W
Then in the editor UI->HUDs->create a new HUD and make the type Navigation Bar.
Here is Ork2 tutorial, basically the same thing.
https://orkframework.com/ork-2/tutorial/gameplay/navigation-bar/
Or I'm sure GiL will have suggestions on Northstar navigator.
Thank you for teaching me so many things.
But the settings are different in ORK3,
so to be honest I didn't really know how to do it.
Instead, I found a way to do it well with Northpoint Navigator.
I placed an empty object in the scene beforehand
so it would attach to the player after the start.
I used Dotween.
I'm not sure if anyone will find this helpful, but
I've included the script.
The player is Warrior, and the empty object is NorthPoint.
Please change the names as appropriate.
using UnityEngine;
using DG.Tweening;
using System.Collections;
public class FollowPlayer : MonoBehaviour
{
public Transform NorthPoint;
private Transform Warrior;
public float duration = 1f; // Duration for the tween
private void Start()
{
// Start a coroutine to wait for Warrior to spawn
StartCoroutine(WaitForWarrior());
}
private IEnumerator WaitForWarrior()
{
// Wait until the Warrior is spawned
while (Warrior == null)
{
GameObject warriorObj = GameObject.Find("Warrior"); // Assuming the Warrior's name is "Warrior"
if (warriorObj != null)
{
Warrior = warriorObj.transform;
}
yield return null; // Wait for the next frame before checking again
}
// Immediately move NorthPoint to Warrior's position and match rotation
NorthPoint.position = Warrior.position;
NorthPoint.rotation = Warrior.rotation;
// Start following the Warrior
Follow();
}
private void Follow()
{
// Make NorthPoint follow Warrior's position using DoTween
NorthPoint.DOMove(Warrior.position, duration).SetEase(Ease.Linear).OnComplete(Follow);
}
private void Update()
{
if (Warrior != null)
{
// Ensure NorthPoint continuously follows Warrior's position and rotation
NorthPoint.DOMove(Warrior.position, duration).SetEase(Ease.Linear);
NorthPoint.DORotateQuaternion(Warrior.rotation, duration).SetEase(Ease.Linear);
}
}
}
1) The player prefab has a script (or e.g. an auto machine) that sets the reference.
I.e. when the player spawns, the compass would get the reference to the player.
2) Use a placed game object in the scene and either have it follow (as your script does) the player or mount it to the player (again, either via script or auto machine).
E.g. an auto machine on the player could search for this game object (by name or tag) and use the Mount Object node to parent that game object to the player.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Thank you very much
As shown above, the problem was solved by attaching a Dotween script that makes an empty object
follow the player as soon as the scene starts.
However, there are still many points I don't understand, so I would like to ask an additional question.
At first, I tried to use the mount node, but it didn't work.
I also tried various nodes such as the move node to move the object, but none of them worked.
In the first setting node of the schematics,
I set the Actor type to GameObject and set the name of the object.
For example, if I try to move it by specifying Object in the move node, it doesn't work at all.
The same goes for the mount node.
I understand that prefabs are spawned in schematics and then work with subsequent nodes.
However, objects don't work with any node, which is very troubling me.
Also, is there a way to move prefabs that are in the scene from the beginning?
Is the setting of the first setting node wrong?
Or did I choose the wrong node?
If you want to find a game object in the scene based on name or tag (or attached components), use the Find Object actor type instead.
Or, depending on your use of the schematic, the machine object or starting object of the schematic could be the object you want to use/move. E.g. the machine object is usually the game object the machine component is attached to.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I had not realized until now that can register objects on the Inspector component.
I thought everything needed to be registered in the Schematics section.
And when I set the rock object in the Actor field of the AutoMachine, it floated perfectly.
You were a big help.
Thank you very much.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!