- Home /
Question by
LBernard1431 · Jan 18, 2021 at 03:21 PM ·
cameraerror message
Screen position out of view frustum (screen pos 574.000000, 266.000000) (Camera rect 0 0 1149 531) UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)
code:
using UnityEngine; using System.Collections;
public class movement : MonoBehaviour { //Variables public float speed = 6.0F; public float jumpSpeed = 8.0F; public float gravity = 20.0F; private Vector3 moveDirection = Vector3.zero; public Transform cam; public float turnSmoothTime = 0.1f; float turnSmoothVelocity;
void Update()
{
CharacterController controller = GetComponent<CharacterController>();
// is the controller on the ground?
if (controller.isGrounded)
{
//Feed moveDirection with input.
float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("Vertical");
Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
//Multiply it by speed.
moveDirection *= speed;
//Jumping
if (Input.GetButton("Jump"))
moveDirection.y = jumpSpeed;
}
//Applying gravity to the controller
moveDirection.y -= gravity * Time.deltaTime;
//Making the character move
controller.Move(moveDirection * Time.deltaTime);
if (moveDirection.magnitude >= 0.1f)
{
float targetAngle = Mathf.Atan2(moveDirection.x, moveDirection.z) * Mathf.Rad2Deg;
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
transform.rotation = Quaternion.Euler(0f, targetAngle, 0f);
controller.Move(moveDirection * Time.deltaTime);
}
Cursor.lockState = CursorLockMode.Locked;
}
}
Comment
Answer by xogur6889 · Jan 18, 2021 at 05:02 PM
When you use 2D effect (UI, Line Render..) You should check elements’s Screen position is not in camera’s near or far clip
Your answer
![](https://koobas.hobune.stream/wayback/20220613023526im_/https://answers.unity.com/themes/thub/images/avi.jpg)