Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Spin.cs using System.Collections; using System.Collections.Generic; using UnityEngine; public class SpinScript : MonoBehaviour { public float spinRate = 1 5 f; / / Start is called
Spin.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpinScript : MonoBehaviour
public float spinRate f;
Start is called before the first frame update
void Start
Update is called once per frame
void Update
transform.Rotate spinRate Time.deltaTime, ;
MouseLook.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
public enum RotationAxes
MouseXAndY
MouseX
MouseY
public RotationAxes axes RotationAxes.MouseXAndY;
public float sensitivityHor f;
public float sensitivityVert f;
public float minimumVert f;
public float maximumVert f;
private float verticalRot f;
Start is called before the first frame update
void Start
Rigidbody body GetComponent;
ifbody null
prevent physics rotations
body.freezeRotation true;
Update is called once per frame
void Update
if axes RotationAxes.MouseX
horizontal rotaiton here
transform.Rotate sensitivityHor Input.GetAxisMouse X;
else if axes RotationAxes.MouseY
vertical rotation here
verticalRot Input.GetAxisMouse Y sensitivityVert;
verticalRot Mathf.ClampverticalRot minimumVert, maximumVert;
float horizontalRot transform.localEulerAngles.y;
transform.localEulerAngles new VectorverticalRot horizontalRot, ;
else
horizontal and vertical rotation here
verticalRot Input.GetAxisMouse Y sensitivityVert;
verticalRot Mathf.ClampverticalRot minimumVert, maximumVert;
float delta Input.GetAxisMouse X sensitivityHor;
float horizontalRot transform.localEulerAngles.y delta;
transform.localEulerAngles new VectorverticalRot horizontalRot, ;
FPSInput.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FPSInput : MonoBehaviour
public float speed f;
public float gravity f;
private CharacterController charController;
Start is called before the first frame update
void Start
charController GetComponent;
Update is called once per frame
void Update
float deltaX Input.GetAxisHorizontal speed Time.deltaTime;
float deltaZ Input.GetAxisVertical speed Time.deltaTime;
transformTranslatedeltaX deltaZ;
instead of using the above to move the character, we can simply use the character controller
float deltaX Input.GetAxisHorizontal speed;
float deltaZ Input.GetAxisVertical speed;
Vector movement new VectordeltaX deltaZ;
ensure we don't move too fast
movement VectorClampMagnitudemovement speed;
apply gravity
movement.y gravity;
make movement frame dependent
movement Time.deltaTime;
transform from local to global
movement transform.TransformDirectionmovement;
move charater controller
charController.
Movemovement;
These are the scripts provided. Please answer the following, will rate up
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started