Nowhere is my question:
Im making a 3D space game, and before i do anything i need my players to be able to look around.
Because this is in space and the players have jetpacks, the players body should rotate with EVERY mouse movement, that means it rotates around x and y at the same time.
Here is my problem:
I know how to make it so the camera turns around x / y axis but not both, and i need a script that is simple and handles both in one camera.
I currently use transform.Rotate, this works fine for y and x axis on their own, but when i do both together, and move the camera around x and y at the same time (ingame) it will start rotating weirdly.
Thanks in advance and again i need:
-simple code
-in one script bound to the cam
-that moves in every direction without weird tilting
Ok but i have seen different scripts but smaller. I am new to c# but there might be some unnecessary parts. For example: he made a float for the clamping but he could have just wrote the number 90 and -90
The FreeCamera component provides you with an implementation for a simple free camera. When you add this component to a Camera, you can use the keyboard and mouse, or a controller, to control the Camera's position and rotation in Play Mode.
Any script that bridges two assets together will need to account for the way in which you want to integrate them. The exact functions involved will depend on the asset you're using, but the main takeaway from the tutorial is that - in a typical case - AC should be able to control the character during cutscenes - and the other motion controller during gameplay (unless point-and-click motion is involved).
Update: I've been looking into the controller on my end. It does seem fairly basic, and not too well suited to being integrated with other assets without modifying the motion controller's code itself.
Though, since the controller also deals with the camera motion, this will also prevent the camera from being controllable. To get around this, you would have to move the ThirdPersonController script's camera-related code into a separate script so that it is unaffected.
Yes, I already did what you suggest. Basically as far as I know after understanding the script you wrote above, It will deactivate ThirdPersonController script while certain conditions are met right (i.e. Pausing, cutscenes) ?
I tried the latter approach, but the process of converting an input direction into a movement direction is handled from within ThirdPersonController, which causes issues if the camera moves during an AC cutscene.
With the approach of disabling ThirdPersonController completely, it'll be necessary to leverage AC's Mecanim animation engine to have the character animate properly during cutscenes. I myself don't encounter the issue you face in the video, but it may be a case of execution orders - since both AC and ThirdPersonController are competing for control over the Animator's "Speed" parameter.
One way to get around this would be to update the relative Script Execution Order values between AC's StateHandler component (which handles AC's updating) and the ThirdPersonController. If ThirdPersonController's is higher, it'll update 2nd and in theory apply it's own change over the Speed parameter after AC.
The other way would be to have the integration script clear the "Speed" parameter from the Player's Inspector when not in a cutscene, so that it doesn't control it when it shouldn't. Something like this:
To switch between different Cinemachine cameras, yes: it's a case of changing each's priority. AC will treat the Cinemachine Brain as a single GameCamera, so it's not possible to use AC's Camera: Switch Action to switch between individual Cinemachine VirtualCameras.
An ActionList will, by default, block gameplay - yes. You can configure this at the top of its Inspector with its "When running" field. Setting this to "Run In Background" will allow gameplay to continue while it runs.
So long as its the Cinemachine Brain you make visible to AC (by attaching AC's Basic Camera component to it), then it can be treated like a regular GameCamera regardless of what Cinemachinr VirtualCamera it's actually representing. You would be able to use other AC cameras using Actions in cutscenes as normal.
This method also allows you to use AC's MainCamera tracks in Timeline, allowing you to switch camera within Timeline sequences as well as within ActionLists - more on this can be found in the Manual's "Working with Timeline" section.
AC's MainCamera and CM's "Cinemachine Brain" camera need to be separate objects. If AC's MainCamera is missing, you can auto-add it by clicking "Without folders" at the top of the Scene Manager - but check that your current MainCamera doesn't have both the Cinemachine Brain and MainCamera components.
The controller example scene provided with the Magic Leap Unity Examples Project provides developers with simple demonstrations of typical controller interactions. The included prefabs utilize the XR Interaction Toolkit(XRI) for familiar interaction standards and direct access to Unity events. This project gives you an excellent starting point for becoming familiar with the tools and scripts that allow you to take full advantage of the Magic Leap 2 controller.
Data for input and controller bindings are configured in the Magic Leap Input Asset, which utilizes the Unity Input System. The Input Asset can be found in the Magic Leap SDK package located in: Packages/Magic Leap SDK/Subsystems/Input.
This script contains examples of subscribing to controller events and sample data from each event. These events are closely tied to the Magic Leap Inputs Asset in the Magic Leap SDK package (explained above and found at Packages/Magic Leap SDK/Subsystems/Input).
This tutorial is designed to get you up and running with Unity as quickly as possible by showing you how to create a simple player controller system. This player controller and corresponding camera controller system can easily be applied to different types of game player objects such as first person, third person, physics based players, and different types of vehicles.
Firstly I was interested in using physics based players. An example of this is the rolling ball in the Unity Roll a ball tutorial. Other physics based players can include things like flying or rolling vehicles. Physics based movement can be tricky to work with but it also lends itself well to physics based interactions with other physics based objects in the game environment.
Another reason why I wanted to investigate a relatively simpler method for player movement is because I am interested in developing player controls that can be more easily translated to working with mobile devices that do not normally have a mouse input option. My idea here is that I could create simple UI buttons that could be tapped on mobile devices to control the movement, similar to say the mobile / joystick control systems that you can find in the Unity Asset Store and Youtube.
The advantage of this system is that you can adjust the position of the camera to either look at your player as in a third person game or be in the position of your player as in a first person game. And, if your player is rotating or spinning around due to rolling or collisions etc this does not necessarily affect the rotation of camera. For a first person controller you can simply turn off the mesh rendering of your player object, in which case the rigid body (or say physical shape) of your player can still interact with the physical environment.
Input Actions must be enabled through the Input Action Manager. To add them manually, locate the Input Action Manager script and add an Input Action asset as an element. These assets are located in the samples path under Shared Assets > Input Actions.
The XR Controller Manager will filter what XRControllerProfile is used in the application based on what InputDevice is connected. Please refer to the Unity documentation for Microsoft Mixed Reality Motion Controller Profile or Oculus Touch Controller Profile.
If the Host Controller is being used, the Device Pointer will be activated. The Device Pointer contains the Host Controller mesh and input references. If a VR device with two controllers is being used, the XR Controllers GameObject will be activated. The XR Controllers prefab contains two GameObjects for the left and right controller with an XR Controller (Action Based Controller) component with references to each controller prefab and the specific input references.
The Interaction prefab is a more complex prefab that can be used for switching between the different interaction methods. It is included in the Snapdragon Spaces Samples and contains three prefabs for the different interaction methods currently supported. The XR Interaction Toolkit Sample scene can be used as an example of how to use this prefab and it's components.
The Interaction Manager component is in the root GameObject of this prefab. It contains the methods for the different interaction input modalities as well as the code that handles input interaction switching.
For AR Devices, the default configuration will start with Hand Tracking and fallback to the Gaze Pointer if the QCHT package is not included in the Unity project or if Hand Tracking is not compatible with the target device. Otherwise it will switch from Hand Tracking > Gaze Pointer > Device Input.
For VR/MR Devices, if a controller is tracked, it will automatically start with XR Controllers as the default input modality. Otherwise it will start with Hand Tracking as the default input modality. The Automatic Controller Switch component in the Interaction prefab detects the controller tracked status and automatically disables Hand Tracking when a controller is tracked or enables Hand Tracking when there are no controllers tracked. The user can switch between XR Controllers/Hand Tracking and Gaze Pointer input modality pressing the Menu button on the left controller.
3a8082e126