utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine;
public class Motion : MonoBehaviour
{
// refrences
[SerializeField]float moveSpeed;
[SerializeField]float walkSpeed;
[SerializeField]float runSpeed;
[SerializeField]LayerMask groundMask;
[SerializeField]float gravity;
[SerializeField]float groundDistance;
[SerializeField]bool isGrounded;
[SerializeField]float jumpDistance;
personal Vector3 motion;
personal Vector3 depth;
CharacterController management;
Animator Ani;
// Begin is named earlier than the primary body replace
void Begin()
{
management = GetComponent<CharacterController>();
Ani = GetComponentInChildren<Animator>();
}
// Replace is named as soon as per body
void Replace()
{
Transfer();
}
void Transfer(){
float movez = Enter.GetAxis("Vertical");
motion = new Vector3(0, 0, movez);
motion = remodel.TransformDirection(motion);
isGrounded = Physics.CheckSphere(remodel.place, groundDistance, groundMask);
if(isGrounded && depth.y < 0){
depth.y = -1;
}
movementBranch = Ani.SetBool("isMoving",true);
if(movementBranch == true){
MovementAnimation();
}
motion *= moveSpeed;
if(Enter.GetKey(KeyCode.House)){
Leap();
}
// if(motion != Vector3.zero && Enter.GetKey(KeyCode.LeftShift) && !Enter.GetKey(KeyCode.C)){
// Slidefalse();
// MovementAnimation();
// }
// else if(motion != Vector3.zero && Enter.GetKey(KeyCode.LeftShift) && Enter.GetKey(KeyCode.C)){
// Slidetrue();
// }
management.Transfer(motion * Time.deltaTime);
depth.y += gravity * Time.deltaTime;
management.Transfer(depth * Time.deltaTime);
}
void Stroll(){
moveSpeed = walkSpeed;
Ani.SetFloat("velocity", 0f, 0.1f, Time.deltaTime);
}
void Run(){
moveSpeed = runSpeed;
Ani.SetFloat("velocity", 1f, 0.1f, Time.deltaTime);
}
// void Idle(){
// Ani.SetFloat("velocity", 0, 0.1f, Time.deltaTime);
// }
void Leap(){
depth.y = Mathf.Sqrt(jumpDistance * -1 * gravity);
}
// void Slidetrue(){
// Ani.SetBool("isSliding", true);
// }
// void Slidefalse(){
// Ani.SetBool("isSliding", false);
// }
// void Movetree(){
// Ani.SetBool("isMoving",true);
// }
void Sliding(){
Ani.SetFloat("velocity", 2f ,0.1f ,Time.deltaTime);
}
void MovementAnimation(){
if(isGrounded )
{
if(motion != Vector3.zero && !Enter.GetKey(KeyCode.LeftShift) && !Enter.GetKey(KeyCode.C)){
Stroll();
}
else if(motion != Vector3.zero && Enter.GetKey(KeyCode.LeftShift) && !Enter.GetKey(KeyCode.C)){
Run();
}
else if(motion != Vector3.zero && Enter.GetKey(KeyCode.LeftShift) && Enter.GetKey(KeyCode.C)){
Sliding();
}
}
}
}
The issue is available in transfer(){
movementBranch = Ani.SetBool(“isMoving”,true);}
making an attempt to make a variable for the animator,setbool so i could make an if assertion for the stroll run and sliding animations work however its not strolling unity retains saying AssetsScriptMovement.cs(49,12): error CS0103: The identify ‘movementBranch’ doesn’t exist within the present context. So pls any assist is useful