Jump to content
Unity Insider Forum

dieDoub

Newbie
  • Gesamte Inhalte

    1
  • Benutzer seit

  • Letzter Besuch

Alle erstellten Inhalte von dieDoub

  1. dieDoub

    Error CS0019

    Hallo. ich habe mir ein Video auf Youtube angesehen wegen das Lernen vom Programmieren habe alles so eingegebn wie es gesasgt wurde doch nun kam die Fehlermeldung mit error CS0019. operator "+" cannot be applied to operands of Type "Vector3" and "float" ich habe alles probiert und durchsucht aber kein lösungsweg gefunden Hier mein Script: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Playercontroller : MonoBehaviour { public float walkingSpeed = 8.0f; public float runningSpeed = 12.0f; public float jumpSpeed = 8.0f; public float gravity = 18.0f; public Camera playerCamera; public float lookSpeed = 2.5f; public float lookXLimit = 45.0f; CharacterController characterController; Vector3 moveDirection = Vector3.zero; float rotationX = 0; [HideInInspector] public bool canMove = true; // Start is called before the first frame update void Start() { characterController = GetComponent<CharacterController>(); //locking cursor Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } // Update is called once per frame void Update() { Vector3 forward = transform.TransformDirection(Vector3.forward); Vector3 right = transform.TransformDirection(Vector3.right); //Left Shift to Run bool isRunning = Input.GetKey(KeyCode.LeftShift); float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0; float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0; float movementDirectionY = moveDirection.y; moveDirection = (forward + curSpeedX) + (right * curSpeedY); //Jumping if(Input.GetButton("Jump") && canMove && characterController.isGrounded) { moveDirection.y = jumpSpeed; } else { moveDirection.y = movementDirectionY; } //Gravity if(!characterController.isGrounded) { moveDirection.y -= gravity * Time.deltaTime; } //Moving characterController.Move(moveDirection * Time.deltaTime); //Camera Rotation 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); } } }
×
×
  • Neu erstellen...