can i find whats the problem of the script of free camera rotation ??
using System.Collections; using UnityEngine;
public class BallCamera : MonoBehaviour {
public float moveSpeed = 5.0f;
public float drag = 0.5f;
public float terminalRotationSpeed = 25.0f;
public Vector3 MoveVector { set; get; }
public VirtualJoystick JoyStick { set; get; }
private Rigidbody thisRigidbody;
private Transform camTransform;
private void Start()
{
thisRigidbody = gameObject.AddComponent<Rigidbody>();
thisRigidbody.maxAngularVelocity = terminalRotationSpeed;
thisRigidbody.drag = drag;
}
private void Update() { //Get the original input MoveVector = PoolInput();
//Move Vector
MoveVector = RotateWithView();
//Move
Move();
}
private void Move() { thisRigidbody.AddForce((MoveVector * moveSpeed)); }
private Vector3 PoolInput() { Vector3 dir = Vector3.zero;
dir.x = JoyStick.Horizontal();
dir.z = JoyStick.Vertical();
if (dir.magnitude > 1)
dir.Normalize();
return dir;
}
private Vector3 RotateWithView() { if (camTransform != null) { Vector3 dir = camTransform.TransformDirection(MoveVector); dir.Set(dir.x, 0, dir.z); return dir.normalized * MoveVector.magnitude; } else { camTransform = Camera.main.transform; return MoveVector;
}
} }
that was the script aand now im showing the error console ...
Type VirtualJoystick' does not contain a definition for
Horizontal' and no extension method Horizontal' of type
VirtualJoystick' could be found. Are you missing an assembly reference? Type VirtualJoystick' does not contain a definition for
Vertical' and no extension method Vertical' of type
VirtualJoystick' could be found. Are you missing an assembly reference?
i have also the other script that is related to this one
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class FreeCamera : MonoBehaviour {
public VirtualJoystick JoyStick{set;get;}
private Transform thisTransform;
private Camera cam;
public Transform CamTransform{set;get;}
private const float Y_ANGLE_MIN = 0.0f;
private const float Y_ANGLE_MAX = 180.0f;
private float distance = 5.0f;
private float currentX = 0.0f;
private float currentY = 0.0f;
private float sensivityX = 3.0f;
private float sensivityY = 1.0f;
private void Start()
{
CamTransform = new GameObject("Camera Container").transform;
cam = CamTransform.gameObject.AddComponent<Camera>();
cam.tag = "MainCamera";
thisTransform = transform;
}
private void Update() {
currentX += JoyStick.Horizontal() * sensivityX;
currentY += JoyStick.Vertical() * sensivityY;
currentY = ClampAngle(currentY, Y_ANGLE_MIN, Y_ANGLE_MAX);
}
private void LateUpdate()
{
Vector3 dir = new Vector3(0, 0, -distance);
Quaternion rotation = Quaternion.Euler(currentY, currentX, 0);
CamTransform.position = thisTransform.position + rotation * dir;
CamTransform.LookAt (thisTransform.position);
}
private float ClampAngle(float angle, float min, float max)
{
do
{
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
} while (angle < -360 || angle > 360);
return Mathf.Clamp(angle, min, max);
}
}
console errors .. Assets/FreeCamera.cs(34,30): error CS1061: Type VirtualJoystick' does not contain a definition for
Horizontal' and no extension method Horizontal' of type
VirtualJoystick' could be found. Are you missing an assembly reference?
Assets/FreeCamera.cs(35,30): error CS1061: Type VirtualJoystick' does not contain a definition for
Vertical' and no extension method Vertical' of type
VirtualJoystick' could be found. Are you missing an assembly reference?
pls help what is the problem ,answer me pls
Answer by meat5000 · Apr 07, 2018 at 01:34 PM
To access your joystick, you need to use GetComponent to reference it. Youve defined it in the class, all good... now populate it with a reference to your actual joystick with GetComponent in Start(). If this still doesnt work, check said methods exist, are spelled the same and are not private.
Your answer
Follow this Question
Related Questions
Multi-display Mac Big Sur and Android Touch display 0 Answers
Unity3D accelerometer camera rotation realistic controls 0 Answers
Set the rotation axis of the camera 0 Answers
How to make the camera NOT rotate with it's father 1 Answer
Unity 2017 .3.1f1 - Android build camera UI flags issue. 0 Answers