mirror of
https://github.com/RaindropViewer/RaindropViewer.git
synced 2026-08-14 09:02:13 +00:00
Added a scene that allow us to test orbital camera and facing direction joystick is working
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 037a0c6dece827f43bd41172f698c62a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,131 @@
|
||||
using Lean.Gui;
|
||||
using Raindrop;
|
||||
using Raindrop.Presenters;
|
||||
using Raindrop.ServiceLocator;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Raindrop.Rendering;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(UpdateMovementBackend))]
|
||||
[RequireComponent(typeof(PlayerFacingInput))]
|
||||
// character will move in same direction as the joystick in the camera's current view direction.
|
||||
public class JoystickCameraRelativeCharacterControl : MonoBehaviour
|
||||
{
|
||||
//public float playerRotationspeed = 0.02f;
|
||||
public LeanJoystick js;
|
||||
public Transform cam;
|
||||
public Vector2 joyinput;
|
||||
public Vector3 agent_DirectionOfMovement;
|
||||
public Transform player;
|
||||
private Vector3 playerLookAt;
|
||||
public float camAngle;
|
||||
public float joyAngle;
|
||||
private float joyThreshold = 0.1f;
|
||||
|
||||
public UpdateMovementBackend WASDInput;
|
||||
public PlayerFacingInput playerHeadingInput;
|
||||
|
||||
public AgentPresenter agents;
|
||||
public bool debug;
|
||||
|
||||
private RaindropInstance instance { get { return ServiceLocator.Instance.Get<RaindropInstance>(); } }
|
||||
//private RaindropNetcom netcom { get { return instance.Netcom; } }
|
||||
bool Active => instance.Client.Network.Connected;
|
||||
|
||||
void Start()
|
||||
{
|
||||
js = this.GetComponent<LeanJoystick>();
|
||||
if (js == null)
|
||||
{
|
||||
Debug.LogError("bad hook up!");
|
||||
}
|
||||
|
||||
WASDInput = this.GetComponent<UpdateMovementBackend>();
|
||||
if (WASDInput == null)
|
||||
{
|
||||
Debug.LogError("bad hook up!");
|
||||
}
|
||||
playerHeadingInput = this.GetComponent<PlayerFacingInput>();
|
||||
if (playerHeadingInput == null)
|
||||
{
|
||||
Debug.LogError("bad hook up!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (!Active && !debug)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
if (agents.agentReference != null) //todo: ok we should do a event driven way instead
|
||||
{
|
||||
player = agents.agentReference.transform;
|
||||
} else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
//1. get camera's heading as a euler around y.
|
||||
camAngle = cam.transform.localEulerAngles.y; //ACW-angle from "north"
|
||||
|
||||
//2. get joy's heading as a 2d vector in screen space. (x,y)
|
||||
joyinput = js.ScaledValue;
|
||||
if (joyinput.magnitude < joyThreshold)
|
||||
{
|
||||
StopMovement();
|
||||
return;
|
||||
}
|
||||
|
||||
joyinput.Normalize();
|
||||
|
||||
//2b. get 2Djoy's angle from north as a Radians float (since north is our UI's frame of reference; the 0 degrees)
|
||||
//var joyForward = Vector2.up;
|
||||
//var theta = Vector2.SignedAngle(joyForward, joyinput);
|
||||
|
||||
//3. rotate camera's forward vector on Y axis by this 2Djoy angle.
|
||||
//agent_DirectionOfMovement = Quaternion.Euler(0, theta, 0) *
|
||||
// Quaternion.Euler(0, camEulerY,0 ) *
|
||||
// (Vector3.forward);
|
||||
|
||||
//2 ok, so berkley is very smart and concise:
|
||||
joyAngle = Mathf.Atan2(joyinput.x, joyinput.y) * Mathf.Rad2Deg; //CW-angle from "north"
|
||||
float finalAngle = joyAngle + camAngle; //degrees.
|
||||
|
||||
agent_DirectionOfMovement = Quaternion.Euler(0, finalAngle, 0) * Vector3.forward;
|
||||
|
||||
OrientPlayer(agent_DirectionOfMovement);
|
||||
MoveForwardInDirection();
|
||||
}
|
||||
|
||||
private void OrientPlayer(Vector3 agentFacingDirection)
|
||||
{
|
||||
//var newEuler = Vector3.Lerp(playerEuler, agent_DirectionOfMovement, Time.deltaTime * playerRotationspeed);
|
||||
playerLookAt = player.transform.position + agentFacingDirection;
|
||||
player.LookAt(playerLookAt, Vector3.up);
|
||||
|
||||
var heading_lefthanded = player.eulerAngles.y;
|
||||
playerHeadingInput.OnHeadingSet(heading_lefthanded);
|
||||
}
|
||||
|
||||
private void MoveForwardInDirection()
|
||||
{
|
||||
WASDInput.OnWASDSet(true, false, false, false);
|
||||
}
|
||||
private void StopMovement()
|
||||
{
|
||||
WASDInput.OnWASDSet(false, false, false, false);
|
||||
}
|
||||
|
||||
public void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.DrawLine(player.transform.position ,player.transform.position + agent_DirectionOfMovement*100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efbb001fed888a24780db1e14c20cb8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using Cinemachine;
|
||||
using Lean.Gui;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public class JoystickControlOrbitalCamera : MonoBehaviour
|
||||
{
|
||||
public float sensX = 0.4f;
|
||||
public float sensY = 0.1f;
|
||||
public LeanJoystick js;
|
||||
|
||||
public Cinemachine.CinemachineFreeLook freelook;
|
||||
private float JoyThreshold = 0.1f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
js = this.GetComponent<LeanJoystick>();
|
||||
if (js == null)
|
||||
{
|
||||
Debug.Log("bad hook up!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
var joyinput = js.ScaledValue;
|
||||
if (joyinput.magnitude < JoyThreshold)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
freelook.m_XAxis.Value += joyinput.x * sensX * Time.deltaTime;
|
||||
freelook.m_YAxis.Value += joyinput.y * sensY * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd58edfd2df65a74a9f2fac448eeac93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using OpenMetaverse;
|
||||
using Raindrop;
|
||||
using Raindrop.Netcom;
|
||||
using Raindrop.Rendering;
|
||||
using Raindrop.ServiceLocator;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Vector3 = OpenMetaverse.Vector3;
|
||||
using OMV = OpenMetaverse;
|
||||
|
||||
// send current player's heading to the backend. We are authoritative on this, as the viewer.
|
||||
// we can send it in a lerp-y way, as we slowly turn in the scene.
|
||||
public class PlayerFacingInput : MonoBehaviour
|
||||
{
|
||||
private RaindropInstance instance { get { return ServiceLocator.Instance.Get<RaindropInstance>(); } }
|
||||
private RaindropNetcom netcom { get { return instance.Netcom; } }
|
||||
private GridClient client { get { return instance.Client; } }
|
||||
bool Active => instance.Client.Network.Connected;
|
||||
|
||||
//left handed; starting from forward in world space - clockwise from top-down
|
||||
public void OnHeadingSet(float heading_lefthanded)
|
||||
{
|
||||
float heading_righthanded = -heading_lefthanded;
|
||||
instance.Movement.SetHeading(heading_righthanded);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0be296250e9bd3a4db33c052053502ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a18a345812a1a5c43ad09dcc2b28e00c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using Raindrop;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraIdentifier : MonoBehaviour
|
||||
{
|
||||
public CameraType type;
|
||||
|
||||
|
||||
public enum CameraType
|
||||
{
|
||||
Main,
|
||||
Minimap
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e5ebb729f7b4ea5b30c3a829e159158
|
||||
timeCreated: 1644244307
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using OpenMetaverse;
|
||||
using UnityEngine;
|
||||
|
||||
public class CamerasManager : MonoBehaviour
|
||||
{
|
||||
#region Monobehavior Singleton stuff
|
||||
|
||||
private static CamerasManager _instance;
|
||||
|
||||
public static CamerasManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
Debug.LogError("you forget to attach the singleton CamerasManager script.");
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Dictionary<CameraIdentifier.CameraType, Camera> cameras =
|
||||
new Dictionary<CameraIdentifier.CameraType, Camera>();
|
||||
public CameraIdentifier.CameraType currentCam;
|
||||
//private CameraIdentifier.CameraType CurrentCamType;
|
||||
public bool Ready { get; set; } = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//get all cameras.
|
||||
foreach(Transform child in transform)
|
||||
{
|
||||
RegisterCamera(child.gameObject);
|
||||
}
|
||||
|
||||
//get ready for work.
|
||||
Ready = true;
|
||||
|
||||
ActivateCamera(currentCam);
|
||||
}
|
||||
|
||||
private void DeactivateAllCameras()
|
||||
{
|
||||
foreach(var cam in cameras)
|
||||
{
|
||||
cam.Value.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterCamera(GameObject Camera)
|
||||
{
|
||||
Camera cam = Camera.GetComponent<Camera>();
|
||||
var type = Camera.GetComponent<CameraIdentifier>();
|
||||
if (cam && type)
|
||||
{
|
||||
cameras.Add(type.type, cam);
|
||||
}
|
||||
}
|
||||
|
||||
public void ActivateCamera(CameraIdentifier.CameraType type)
|
||||
{
|
||||
if (!Ready)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
currentCam = type;
|
||||
DeactivateAllCameras();
|
||||
cameras[currentCam].enabled = true;
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
OpenMetaverse.Logger.Log("camera not available: " + type.ToString()
|
||||
, Helpers.LogLevel.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f764335f78f0a604b9c150c1cfd2daae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using Raindrop;
|
||||
using Raindrop.Presenters;
|
||||
using Raindrop.ServiceLocator;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
//assign the target for the cinemachine freelook camera to look at.
|
||||
public class RaindropCinemachineAssignLookAtAvatar : MonoBehaviour
|
||||
{
|
||||
private RaindropInstance instance { get { return ServiceLocator.Instance.Get<RaindropInstance>(); } }
|
||||
//private RaindropNetcom netcom { get { return instance.Netcom; } }
|
||||
bool Active => instance.Client.Network.Connected;
|
||||
|
||||
public AgentPresenter agents;
|
||||
public Cinemachine.CinemachineFreeLook cinemachine;
|
||||
private void Update()
|
||||
{
|
||||
TrySetTarget();
|
||||
}
|
||||
public void TrySetTarget()
|
||||
{
|
||||
if (Active)
|
||||
{
|
||||
if (agents.agentReference != null) //todo: ok we should do a event driven way instead
|
||||
{
|
||||
SetCinemachineTarget(agents.agentReference);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void SetCinemachineTarget(GameObject agentReference)
|
||||
{
|
||||
cinemachine.LookAt = agentReference.transform;
|
||||
cinemachine.Follow = agentReference.transform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66e014447e0fa6843af747522de4e852
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37ccbad618f43414fb2ee8295693fa4f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using Lean.Gui;
|
||||
using Raindrop;
|
||||
using Raindrop.ServiceLocator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Raindrop.UI.Movement
|
||||
{
|
||||
[RequireComponent(typeof(Button))]
|
||||
class JumpToBackend : MonoBehaviour , IPointerDownHandler, IPointerUpHandler
|
||||
{
|
||||
private Button btn;
|
||||
|
||||
|
||||
private RaindropInstance instance { get { return ServiceLocator.Instance.Get<RaindropInstance>(); } }
|
||||
//private RaindropNetcom netcom { get { return instance.Netcom; } }
|
||||
bool Active => instance.Client.Network.Connected;
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
DoJump();
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
ReleaseJump();
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
btn = GetComponent<Button>();
|
||||
}
|
||||
|
||||
private void ReleaseJump()
|
||||
{
|
||||
if (Active)
|
||||
{
|
||||
instance.Movement.Jump = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DoJump()
|
||||
{
|
||||
if (Active)
|
||||
{
|
||||
instance.Movement.Jump = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3aa6bf3d4a212ec4eb2a5550a6721485
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Gui;
|
||||
using Raindrop;
|
||||
using Raindrop.Rendering;
|
||||
using Raindrop.ServiceLocator;
|
||||
using UnityEngine;
|
||||
using Camera = UnityEngine.Camera;
|
||||
|
||||
// attach this to the main camera to update the backend on where the avatar is looking at.
|
||||
[RequireComponent(typeof(Camera))]
|
||||
public class UpdateCameraBackend : MonoBehaviour
|
||||
{
|
||||
|
||||
private RaindropInstance instance { get { return ServiceLocator.Instance.Get<RaindropInstance>(); } }
|
||||
//private RaindropNetcom netcom { get { return instance.Netcom; } }
|
||||
bool Active => instance.Client.Network.Connected;
|
||||
|
||||
public Camera cam;
|
||||
void Start()
|
||||
{
|
||||
cam = this.GetComponent<Camera>();
|
||||
Debug.LogWarning("the lookat is not implemented, although the far clip is set in the backend.");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Active)
|
||||
{
|
||||
instance.Client.Self.Movement.Camera.Far = cam.farClipPlane;
|
||||
instance.Client.Self.Movement.Camera.Position = RHelp.OMVVector3(cam.transform.position);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Lean;
|
||||
using Raindrop;
|
||||
using OpenMetaverse;
|
||||
using Raindrop.Netcom;
|
||||
using Lean.Gui;
|
||||
using Raindrop.ServiceLocator;
|
||||
using Vector2 = UnityEngine.Vector2;
|
||||
|
||||
//update the backend on user's (u,d,l,r)
|
||||
public class UpdateMovementBackend : MonoBehaviour
|
||||
{
|
||||
private RaindropInstance instance { get { return ServiceLocator.Instance.Get<RaindropInstance>(); } }
|
||||
private RaindropNetcom netcom { get { return instance.Netcom; } }
|
||||
private GridClient client { get { return instance.Client; } }
|
||||
bool Active => instance.Client.Network.Connected;
|
||||
|
||||
// Use this to update the up, down, left, right movements.
|
||||
public void OnWASDSet(
|
||||
bool up,
|
||||
bool down,
|
||||
bool left,
|
||||
bool right)
|
||||
{
|
||||
instance.Movement.SetWasdInput(up,down,left,right);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Gui;
|
||||
using Raindrop;
|
||||
using Raindrop.ServiceLocator;
|
||||
using UnityEngine;
|
||||
|
||||
// currently, this turns the character. in the future, we will use this as input the the 3rd person camera controller.
|
||||
|
||||
[RequireComponent(typeof(LeanJoystick))]
|
||||
public class joystickToCameraBackend : MonoBehaviour
|
||||
{
|
||||
LeanJoystick joy;
|
||||
private RaindropInstance instance;
|
||||
public const float thresh = 0.7f;
|
||||
|
||||
void Start()
|
||||
{
|
||||
joy = this.gameObject.GetComponent<LeanJoystick>();
|
||||
joy.OnSet.AddListener(OnJoySet);
|
||||
|
||||
instance = ServiceLocator.Instance.Get<RaindropInstance>();
|
||||
}
|
||||
|
||||
private void OnJoySet(Vector2 arg0)
|
||||
{
|
||||
|
||||
float vert = arg0.y ; // updown
|
||||
float horz = arg0.x; //left right
|
||||
|
||||
if (isDeadZone(vert, horz, thresh))
|
||||
{
|
||||
instance.Movement.SetTurningStop();
|
||||
instance.Movement.setCameraInputs(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
//
|
||||
// int horz_clamp = (Mathf.Abs(horz) > thresh) ? 1 :
|
||||
// (Mathf.Abs(horz) < thresh) ? -1 :0;
|
||||
//
|
||||
// if (horz_clamp == 0){
|
||||
// instance.Movement.SetTurningStop();
|
||||
// } else if(horz_clamp == 1){
|
||||
// instance.Movement.SetTurningRight();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// instance.Movement.SetTurningLeft();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private bool isDeadZone(float vert, float horz, float thresh)
|
||||
{
|
||||
//get hypo len
|
||||
float a = Mathf.Min(vert, horz);
|
||||
float b = Mathf.Max(vert, horz);
|
||||
float hypo = b + 0.337f * a;
|
||||
|
||||
|
||||
return hypo < thresh;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Lean;
|
||||
using Raindrop;
|
||||
using OpenMetaverse;
|
||||
using Raindrop.Netcom;
|
||||
using Lean.Gui;
|
||||
using Raindrop.ServiceLocator;
|
||||
using Vector2 = UnityEngine.Vector2;
|
||||
|
||||
//make the joystick position drive the user's movement (u,d,l,r) :)
|
||||
public class joystickToMovementBackend : MonoBehaviour
|
||||
{
|
||||
public LeanJoystick variableJoystick;
|
||||
public GameObject theJoystickInScene;
|
||||
public float joyThresh = 0.7f;
|
||||
private RaindropInstance instance { get { return ServiceLocator.Instance.Get<RaindropInstance>(); } }
|
||||
private RaindropNetcom netcom { get { return instance.Netcom; } }
|
||||
private GridClient client { get { return instance.Client; } }
|
||||
|
||||
bool Active => instance.Client.Network.Connected;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (theJoystickInScene.GetComponent<LeanJoystick>() == null)
|
||||
{
|
||||
Debug.LogError("the joystick object is not found!");
|
||||
}
|
||||
variableJoystick = theJoystickInScene.GetComponent<LeanJoystick>();
|
||||
|
||||
//set zero.
|
||||
OnJoyUp();
|
||||
|
||||
variableJoystick.OnUp.AddListener(OnJoyUp);
|
||||
variableJoystick.OnSet.AddListener(OnJoySet);
|
||||
}
|
||||
|
||||
private void OnJoySet(Vector2 arg0)
|
||||
{
|
||||
instance.Movement.set2DInput(arg0);
|
||||
}
|
||||
|
||||
// no more sideways movment.
|
||||
private void OnJoyUp()
|
||||
{
|
||||
if (! Active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
instance.Movement.zero2DInput();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using OpenMetaverse;
|
||||
using Raindrop;
|
||||
using Raindrop.ServiceLocator;
|
||||
using Raindrop.Services;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Camera))]
|
||||
public class RaindropMainCameraDrawDistance : MonoBehaviour
|
||||
{
|
||||
public float DrawDistance;
|
||||
// private UIService ui => ServiceLocator.Instance.Get<UIService>();
|
||||
private RaindropInstance Instance => ServiceLocator.Instance.Get<RaindropInstance>();
|
||||
private GridClient Client => Instance.Client;
|
||||
|
||||
//private bool Active => ui.ScreensManager.TopCanvas.canvasType == CanvasType.Game;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
if (!Instance.GlobalSettings.ContainsKey("draw_distance"))
|
||||
{
|
||||
Instance.GlobalSettings["draw_distance"] = DrawDistance;
|
||||
}
|
||||
|
||||
this.GetComponent<Camera>().farClipPlane = DrawDistance;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
//if (!Active)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 853a9ca7f3ffe584abbe949e540be487
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using Raindrop.Rendering;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RotateQuatUpAxis : MonoBehaviour
|
||||
{
|
||||
//public Vector3 myeuler;
|
||||
public Quaternion myQuat;
|
||||
|
||||
public bool unityversion;
|
||||
public bool stop;
|
||||
|
||||
public OpenMetaverse.Quaternion OMVmyQuat { get; private set; }
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
myQuat = transform.rotation;
|
||||
OMVmyQuat = RHelp.OMVQuaternion4(myQuat);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (stop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (unityversion)
|
||||
{
|
||||
myQuat *= Quaternion.AngleAxis(0.1f, Vector3.up);
|
||||
transform.rotation = myQuat;
|
||||
} else
|
||||
{
|
||||
OMVmyQuat *= OpenMetaverse.Quaternion.CreateFromAxisAngle(OpenMetaverse.Vector3.UnitZ, 0.1f);
|
||||
transform.rotation = RHelp.TKQuaternion4(OMVmyQuat);
|
||||
}
|
||||
//myeuler += new Vector3(0, 0.1f, 0);
|
||||
//this.gameObject.transform.eulerAngles
|
||||
// = myeuler;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 398e857482f89084497e045570b6b0fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,6 +18,23 @@
|
||||
"<GameViewSize>k__BackingField": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"buildTarget": 19,
|
||||
"configurations": [
|
||||
{
|
||||
"configurationName": "Config A",
|
||||
"<DeviceIndex>k__BackingField": 1,
|
||||
"<Orientation>k__BackingField": 2,
|
||||
"<GameViewSize>k__BackingField": 0
|
||||
},
|
||||
{
|
||||
"configurationName": "Config B",
|
||||
"<DeviceIndex>k__BackingField": 0,
|
||||
"<Orientation>k__BackingField": 0,
|
||||
"<GameViewSize>k__BackingField": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"<EnableSimulation>k__BackingField": true,
|
||||
|
||||
@@ -136,7 +136,7 @@ PlayerSettings:
|
||||
16:10: 1
|
||||
16:9: 1
|
||||
Others: 1
|
||||
bundleVersion: 0.24
|
||||
bundleVersion: 0.25
|
||||
preloadedAssets:
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
@@ -159,6 +159,12 @@ PlayerSettings:
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
m_HolographicPauseOnTrackingLoss: 1
|
||||
@@ -176,13 +182,13 @@ PlayerSettings:
|
||||
androidSupportedAspectRatio: 1
|
||||
androidMaxAspectRatio: 2.1
|
||||
applicationIdentifier:
|
||||
Android: com.UnityTestRunner.UnityTestRunner
|
||||
Android: com.RaindropCafe.RaindropViewer
|
||||
Standalone: com.RaindropCafe.RaindropViewer
|
||||
buildNumber:
|
||||
Standalone: 0
|
||||
iPhone: 0
|
||||
tvOS: 0
|
||||
overrideDefaultApplicationIdentifier: 1
|
||||
overrideDefaultApplicationIdentifier: 0
|
||||
AndroidBundleVersionCode: 1
|
||||
AndroidMinSdkVersion: 19
|
||||
AndroidTargetSdkVersion: 0
|
||||
@@ -718,7 +724,7 @@ PlayerSettings:
|
||||
platformArchitecture: {}
|
||||
scriptingBackend:
|
||||
Android: 1
|
||||
Standalone: 0
|
||||
Standalone: 1
|
||||
il2cppCompilerConfiguration:
|
||||
Android: 0
|
||||
managedStrippingLevel: {}
|
||||
|
||||
Reference in New Issue
Block a user