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 /
avatar image
0
Question by SunilUL · Feb 17, 2017 at 10:32 PM · gravityfirst-person-controllercapsulecollider

FPS's Capsule Collider doesn't work when the FPS is translated.

 #pragma strict
 
 private var FPS : GameObject;
 
 function Start () {
     
     FPS = GameObject.Find("FPSController");
 
 }
 
 function Update () {
 if (Input.GetMouseButtonDown(0)) {
 
     var buttonName = EventSystems.EventSystem.current.currentSelectedGameObject.name;
     var VP : GameObject = GameObject.Find(buttonName);   // VP is a viewPoint or Target.
 
 
 FPS.transform.parent = VP.transform;
 Debug.Log(VP);
 FPS.transform.localPosition = Vector3(0,0,0);
 FPS.transform.localEulerAngles = new Vector3(0,0,0);
 FPS.transform.localScale = Vector3(0,0,0);
 
 
     }
 }


The Above code is written to translate the camera form one place to other.. The camera gets translated., but the capsule collider disappears and the camera falls down on the floor.

alt text The Above image is the FPS with collider.

alt text This is without the collider in PlayMode after clicking the VP1 Button(Collider will be present before clicking on the VP button).

Can anyone please let me know what could be the issue here?

camera-with-collider-in-editor-mode.png (266.1 kB)
camera-without-collider-when-clicked-vp1.png (245.2 kB)
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 RobAnthem · Feb 18, 2017 at 01:50 AM 0
Share

What exactly is your code intended to do? Your button should be a delegate, not an event. Your FPS player gets its euler angles set to 0, position to 0,0,0 which is the corner of the map, and you will fall. Then you are setting the entire scale of the object to 0,0,0 which essentially makes it not exist in 3D space. It doesn't destroy it, it is just a size of 0.

avatar image SunilUL RobAnthem · Feb 18, 2017 at 04:22 AM 0
Share

Oh yes, the code is written to move the camera to a specified location on button click. VP is a location., when the button is clicked, it finds the Game object with the name VP. And sets the VP object as a parent to the camera. And when the camera is reset , it takes the transformations of the VP object.

And, yes sorry. Scale should be actually 1,1,1 I think that is creating the problem. Will check ASAP and let you know :)

avatar image SunilUL RobAnthem · Feb 18, 2017 at 08:28 AM 0
Share

Ok, found that the issue is scale..

But, Unable to set the rotation of the FPS to 0.

When i click on Buttons VP1 or VP2, it takes its previous rotation. Its not working when i tried rotating the FPS in runtime manually.

What is the correct way to reset the camera to Position: 0,0,0 Rotation: 0,0,0 and Scale: 0,0,0 ??

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

walking inside curved surface 1 Answer

How do you make gravity for the First Person Controller 3 Answers

Affecting FPS controller/Character Motor physics with game object 1 Answer

Attaching First Person Controller to Kinematic Rigidbody 1 Answer

gravity doesnt seem to effect my first person controller....help! 1 Answer


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