Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by franko-janku · Mar 31, 2018 at 12:13 PM · androidcamerarotationfree

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

226 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges