camRotation script
Vector3 rotation = transform.eulerAngles;
rotation.y -= (Input.GetAxis("Mouse X") * rotationSpeed * Time.deltaTime)*-1;
transform.eulerAngles = rotation;
//this Is the variable I want to move to the other script
diretion_y = rotation.y;
playerMovement script
getAxis_rotation = direction_y;
,
this is the camRot script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class camrot : MonoBehaviour
{
// Start is called before the first frame update
public float rotationSpeed = 500;
public float diretion_y;
void Update()
{
Vector3 rotation = transform.eulerAngles;
rotation.y -= (Input.GetAxis("Mouse X") * rotationSpeed * Time.deltaTime)*-1;
transform.eulerAngles = rotation;
diretion_y = rotation.y;
Debug.Log(diretion_y);
}
}
this is the playerMovement script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class movement : MonoBehaviour
{
// Start is called before the first frame update
public Rigidbody rBody;
public bool jmpRDY;
public float Hinput;
public float Vinput;
public bool isToGround;
public float CICTPY;
here
DebugLog(direction_y);
// Start is called before the first frame update
void Start()
{
rBody = GetComponent<Rigidbody>();
jmpRDY = false;
isToGround = false;
}
// Update is called once per frame
void Update()
{
if(transform.position.y <= CICTPY){
SceneManager.LoadScene( SceneManager.GetActiveScene().name );
}
if(Input.GetKeyDown(KeyCode.Space) && isToGround){
jmpRDY = true;
}
Hinput = Input.GetAxis("Horizontal") *5;
Vinput = Input.GetAxis("Vertical") *5;
}
private void FixedUpdate(){
if (jmpRDY && isToGround){
rBody.AddForce(Vector3.up *7 , ForceMode.VelocityChange);
jmpRDY = false;
isToGround = false;
}
rBody.velocity = new Vector3(Hinput,rBody.velocity.y,Vinput);
}
void OnCollisionEnter(Collision collisionInfo){
if(collisionInfo.collider.tag == "terrain"){
isToGround = true;
}
}
}