G̵̈́͑L̶̈̕1̶̌̀TC̴̑HY
G̵̈́͑L̶̈̕1̶̌̀TC̴̑HY
CC#
Created by G̵̈́͑L̶̈̕1̶̌̀TC̴̑HY on 11/12/2024 in #help
what am i doing wrong
thanks
15 replies
CC#
Created by G̵̈́͑L̶̈̕1̶̌̀TC̴̑HY on 11/12/2024 in #help
what am i doing wrong
moveDirection.y -= gravity * Time.deltaTime; } if (Input.GetKey(KeyCode.C) && canMove) { characterController.height = crouchHeight; walkSpeed = crouchSpeed; runSpeed = crouchSpeed; } else { characterController.height = defaultHeight; walkSpeed = 6f; runSpeed = 12f; } characterController.Move(moveDirection * Time.deltaTime); if (canMove) { rotationX += -Input.GetAxis("Mouse Y") * lookSpeed; rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit); playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0); transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0); } } }
15 replies
CC#
Created by G̵̈́͑L̶̈̕1̶̌̀TC̴̑HY on 11/12/2024 in #help
what am i doing wrong
using System.Collections; using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(CharacterController))] public class PlayerMovement : MonoBehaviour { public Camera playerCamera; public float walkSpeed = 6f; public float runSpeed = 12f; public float jumpPower = 7f; public float gravity = 10f; public float lookSpeed = 2f; public float lookXLimit = 45f; public float defaultHeight = 2f; public float crouchHeight = 1f; public float crouchSpeed = 3f; private Vector3 moveDirection = Vector3.zero; private float rotationX = 0; private CharacterController characterController; private bool canMove = true; void Start() { characterController = GetComponent<CharacterController>(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } void Update() { Vector3 forward = transform.TransformDirection(Vector3.forward); Vector3 right = transform.TransformDirection(Vector3.right); bool isRunning = Input.GetKey(KeyCode.LeftShift); float curSpeedX = canMove ? (isRunning ? runSpeed : walkSpeed) * Input.GetAxis("Vertical") : 0; float curSpeedY = canMove ? (isRunning ? runSpeed : walkSpeed) * Input.GetAxis("Horizontal") : 0; float movementDirectionY = moveDirection.y; moveDirection = (forward * curSpeedX) + (right * curSpeedY); { } if (Input.GetButton("Jump") && canMove && characterController.isGrounded) { moveDirection.y = jumpPower; } else { moveDirection.y = movementDirectionY; } if (!characterController.isGrounded) {
15 replies
CC#
Created by G̵̈́͑L̶̈̕1̶̌̀TC̴̑HY on 11/12/2024 in #help
what am i doing wrong
well heres the code
15 replies
CC#
Created by G̵̈́͑L̶̈̕1̶̌̀TC̴̑HY on 11/12/2024 in #help
what am i doing wrong
do you want the whole code?
15 replies
CC#
Created by G̵̈́͑L̶̈̕1̶̌̀TC̴̑HY on 11/12/2024 in #help
what am i doing wrong
im pretty new to coding so would you mind could maybe help tell me what to put?
15 replies