Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Moving_WASD : MonoBehaviour
- {
- public float speed = 0.1f;
- public Vector3 inertiaVector;
- public bool onLadder;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- if(!GetComponent<Jumping>().inAir)
- {
- if ( Input.GetKey (KeyCode.W ) )
- {
- /if(!GetComponent<Jumping>().inAir)/ transform.position += transform.forward * speed;
- //else inertiaVector = transform.forward;
- }
- if ( Input.GetKey (KeyCode.S ) )
- {
- /if(!GetComponent<Jumping>().inAir)/ transform.position -= transform.forward * speed;
- //else inertiaVector = -transform.forward;
- }
- if ( Input.GetKey (KeyCode.D ) )
- {
- /if(!GetComponent<Jumping>().inAir)/ transform.position += transform.right * speed;
- //else inertiaVector = transform.right;
- }
- if ( Input.GetKey (KeyCode.A ) )
- {
- /if(!GetComponent<Jumping>().inAir)/ transform.position -= transform.right * speed;
- //else inertiaVector = -transform.right;
- }
- }
- }
- void OnTriggerStay (Collider ladder)
- {
- if(ladder.name == "Ladder")
- {
- /GetComponent<Player_WASD>()./onLadder = true;
- GetComponent<Jumping>().inAir = false;
- if(!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.Space))
- {
- GetComponent<Rigidbody>().isKinematic = true;
- if(transform.position.y > ladder.GetComponent<Ladder>().b.position.y)
- {
- Vector3 temp = transform.position;
- temp.y = ladder.GetComponent<Ladder>().b.position.y;
- transform.position = temp;
- }
- if(transform.position.y < ladder.GetComponent<Ladder>().a.position.y)
- {
- Vector3 temp = transform.position;
- temp.y = ladder.GetComponent<Ladder>().a.position.y;
- transform.position = temp;
- }
- if( ( transform.position.y <= ladder.GetComponent<Ladder>().b.position.y ) && ( transform.position.y >= ladder.GetComponent<Ladder>().a.position.y ) )
- {
- if(Input.GetKey(KeyCode.UpArrow)) transform.position += transform.up * speed;
- if(Input.GetKey(KeyCode.DownArrow)) transform.position -= transform.up * speed;
- }
- else
- {
- GetComponent<Rigidbody>().isKinematic = false;
- /GetComponent<Player_WASD>()./onLadder = false;
- }
- }
- }
- }
- else
- {
- GetComponent<Rigidbody>().isKinematic = false;
- /GetComponent<Player_WASD>()./onLadder = false;
- GetComponent<Jumping>().inAir = false;
- }
- }
- }
- void OnTriggerExit (Collider ladder)
- {
- if(ladder.name == "Ladder") { GetComponent<Rigidbody>().isKinematic = false; /GetComponent<Player_WASD>()./onLadder = false; GetComponent<Jumping>().inAir = false;}
- }
- }
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Health : MonoBehaviour
- {
- public float health = 100;
- public bool alive = true;
- public void Update()
- {
- if( health < 0)
- {
- health = 0;
- GetComponent<Renderer>().material.color = Color.red;
- }
- }
- }
- {
- if( Input.GetKey(KeyCode.LeftControl))
- {
- Vector3 tempSize = transform.localScale;
- if(Input.GetKey(KeyCode.LeftShift))
- tempSize.y = heightProne;
- else tempSize.y = heightCrouch;
- transform.localScale = tempSize;
- }
- else
- {
- //Vector3 tempSize = transform.localScale;
- //tempSize.y = height;
- transform.localScale = heightVector;
- }
- if (Physics.Raycast(transform.position, -transform.up, testValue) )
- {
- if ( Input.GetKeyDown (KeyCode.Space ) )
- {
- GetComponent<Rigidbody>().AddForce(transform.up * jumpForceNow);
- //GetComponent<Rigidbody>().AddForce(GetComponent<Moving_WASD>().inertiaVector * testValue2);
- //GetComponent<Moving_WASD>().inertiaVector = Vector3.zero;
- }
- inAir = false;
- }
- else if(!GetComponent<Moving_WASD>().onLadder) inAir = true;
- }
- }
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class HitBox : MonoBehaviour
- {
- public GameObject owner;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement