Jet always follows the cursor.I couldn’t record the cursor on video but I put the cursor at the bottom end of game window. Desired movement is just to rotate around the cursor not move but it moves.
The following code is system code and video is the mentioned video.
using UnityEngine;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
public class PlayerRotationSystem : SystemBase
{
protected override void OnUpdate()
{
var mousePosition = Input.mousePosition;
var cameraRay = Camera.main.ScreenPointToRay(mousePosition);
var layerMask = LayerMask.GetMask("Floor");
if (Physics.Raycast(cameraRay, out var hit, 100, layerMask))
{
Entities.WithAll<PlayerTag>().ForEach((ref Rotation rot, in Translation pos) =>
{
float3 hitPos = hit.point;
float3 relativePos = hitPos - pos.Value;
quaternion rotation = quaternion.LookRotationSafe(relativePos, math.up());
rotation = new quaternion(0, rotation.value.y, 0, rotation.value.w);
rot.Value = rotation;
}).Run();
}
}
}