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 Gugoasa · Jul 29, 2016 at 08:36 PM · rotationcamera rotatechild object

Child OWN Rotation

Hello everyone, i'm new in Unity and i'm trying to do this : I have a Capsule and a Camera. The Camera is a child of the Capsule adn when i try to rotate the Camera with a C# script with transform.rotate the camera rotates, but the Capsule rotates too ! How i can i block the rotation of the Capsule and make it stay in his start position ? I've tried to block the rotations in the rigidbody options but it ain't work :(

Comment
Add comment · Show 3
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
avatar image Firedan1176 · Jul 29, 2016 at 11:17 PM 1
Share

Is your script on the Capsule? If you are rotating transform.rotation, then you need to make sure the script is on the Camera. This is because transform is a variable that applies to the Object your script is attached to.

If your script is on the Capsule and you are rotating transform.rotation, then you're changing the local rotation of the Capsule.

avatar image Gugoasa Firedan1176 · Jul 31, 2016 at 12:47 PM 0
Share

The script with transform.rotation in on the camera , on the capsule i got a script for the movement with tranform.translate :/ I can show u the 2 script if u want

avatar image Gugoasa Firedan1176 · Jul 31, 2016 at 12:51 PM 0
Share

So there it is, the camera is a child of the capsule. CA$$anonymous$$ERA SCRIP : using UnityEngine; using System.Collections;

public class PlayerControl : $$anonymous$$onoBehaviour {

 float xRotation;
 float yRotation;
 float sensitivity = 5.0f;

 // Use this for initialization
 void Start() {
     
 }

 // Update is called once per frame
 void Update() {
     Look();
     
 }

 void Look() {
     xRotation -= Input.GetAxis("$$anonymous$$ouse Y") * sensitivity;
     yRotation += Input.GetAxis("$$anonymous$$ouse X") * sensitivity;

     xRotation = $$anonymous$$athf.Clamp(xRotation, -90, 90);
     transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
 }

}

CAPSULE SCRIPT : using UnityEngine; using System.Collections;

public class Player$$anonymous$$oveControl : $$anonymous$$onoBehaviour {

 float x$$anonymous$$ovement;
 float z$$anonymous$$ovement;
 public float speed = 5.0f;

 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
     $$anonymous$$ove ();
     
 }

 void $$anonymous$$ove(){
     x$$anonymous$$ovement = Input.GetAxis ("Horizontal") * speed * Time.deltaTime;
     z$$anonymous$$ovement = Input.GetAxis ("Vertical") * speed * Time.deltaTime;

     transform.Translate (x$$anonymous$$ovement, 0f, z$$anonymous$$ovement);

 }

}

0 Replies

· Add your reply
  • Sort: 

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

74 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

Related Questions

Camera Controller script as a child object,Camera Control as a Child Object for my Player 0 Answers

How to rotate camera view? 0 Answers

Having problems with doing a smooth isometric rotation around player 0 Answers

Child always on parent top to get the number of dice 0 Answers

How do I make the camera look at three possible perspectives? 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