Adding player and Object Physics

I wish to add Player and object physics but I don’t know we’re to start?
7 Replies
kapa.ai
kapa.ai4mo ago
Hi @Bethink. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To add a player and object physics in NormalVR, you can follow these steps: 1. Create a Player: Start by creating a game object to represent the player. Create an empty game object in the scene named "Player". 2. Add Rigidbody: Add a Rigidbody to the Player game object so that it can respond to physics. Enable Freeze Rotation on every axis to ensure the player remains upright. 3. Add a Sphere: Add a Sphere game object to represent the body of the player. Set the scale of the sphere to 1.8 and set the y-position at 0.9 so the bottom is lined up with the ground. 4. Create a Player Script: Create a new script called Player, and add it to the Player game object. This script will control the player's movements. Here's a sample of how the script might look:
using UnityEngine;

public class Player : MonoBehaviour {
// Physics
private Vector3 _targetMovement;
private Vector3 _movement;

private Rigidbody _rigidbody;

private void Awake() {
// Set physics timestep to 60hz
Time.fixedDeltaTime = 1.0f/60.0f;

// Store a reference to the rigidbody for easy access
_rigidbody = GetComponent<Rigidbody>();
}

private void Update() {
// Use WASD input and the camera look direction to calculate the movement target
CalculateTargetMovement();
}

private void FixedUpdate() {
// Move the player based on the input
MovePlayer();
}

private void CalculateTargetMovement() {
// Get input movement. Multiple by 6.0 to increase speed.
Vector3 inputMovement = new Vector3();
inputMovement.x = Input.GetAxisRaw("Horizontal") * 6.0f;
inputMovement.z = Input.GetAxisRaw("Vertical") * 6.0f;
_targetMovement = inputMovement;
}

private void MovePlayer() {
// Start with the current velocity
Vector3 velocity = _rigidbody.velocity;
}
}
using UnityEngine;

public class Player : MonoBehaviour {
// Physics
private Vector3 _targetMovement;
private Vector3 _movement;

private Rigidbody _rigidbody;

private void Awake() {
// Set physics timestep to 60hz
Time.fixedDeltaTime = 1.0f/60.0f;

// Store a reference to the rigidbody for easy access
_rigidbody = GetComponent<Rigidbody>();
}

private void Update() {
// Use WASD input and the camera look direction to calculate the movement target
CalculateTargetMovement();
}

private void FixedUpdate() {
// Move the player based on the input
MovePlayer();
}

private void CalculateTargetMovement() {
// Get input movement. Multiple by 6.0 to increase speed.
Vector3 inputMovement = new Vector3();
inputMovement.x = Input.GetAxisRaw("Horizontal") * 6.0f;
inputMovement.z = Input.GetAxisRaw("Vertical") * 6.0f;
_targetMovement = inputMovement;
}

private void MovePlayer() {
// Start with the current velocity
Vector3 velocity = _rigidbody.velocity;
}
}
This script captures player input in Update() and applies the input to the rigidbody in FixedUpdate(). The CalculateTargetMovement() method is used to get the input movement and the MovePlayer() method is used to move the player based on the input. For more details, you can refer to the Creating a Player Controller (https://normcore.io/documentation/guides/creating-a-player-controller#creating-a-singleplayer-player-controller) guide in the Normcore documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@1015072230864064703> kapa.ai is still learning and improving, please let us know how it did by reacting below
Bethink PSVR2 🔛🔝🔥
@Normcore Assistant Is Normcore compatible with PSVR2
kapa.ai
kapa.ai4mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Based on the provided knowledge sources, Normcore supports PlayStation VR, but there is no specific mention of PlayStation VR 2 (PSVR2). Normcore currently supports all platforms supported by Unity 2020 LTS, including PlayStation VR. However, some platforms are only available to Normcore Private customers to cover support costs and ensure compliance with console partner restrictions. If you have specific questions about PSVR2 support, I recommend joining the Normcore Discord (https://normcore.io/discord) and asking the team directly. They are usually very responsive and can provide the most accurate and up-to-date information. For more details, you can refer to the Platforms (https://normcore.io/documentation/platforms) page in the Normcore documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@1015072230864064703> kapa.ai is still learning and improving, please let us know how it did by reacting below
maxweisel
maxweisel4mo ago
@Bethink Normcore does support PSVR2 on our public infrastructure btw
Bethink PSVR2 🔛🔝🔥
I see Thanks a lot!