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
-1
Question by savanluffy · Jul 09, 2017 at 03:21 PM · first-person-controllerparent-childparent transformchild-to-gameobject

GameObject won't move after got child

Sorry for the basic question, I am quite new in unity. So I use the FPS Controller from Unity. That is also my parent game object. I have another game object which is a book with the script down below..

So the problem is that after I set the parent of the book. I cant move.... I don't get an error or something.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityStandardAssets.Characters.FirstPerson;
 using UnityEngine.UI;
 public class bookCollider : MonoBehaviour {
 
     FirstPersonController playerController=null;
     public Text clicktext;
     private bool isInTrigger=false;
 
     GameObject gameControllerObject;
 
     void Start(){
          gameControllerObject = GameObject.FindGameObjectWithTag ("FirstPersonController");
 
         if (gameControllerObject != null)
         {
             playerController = gameControllerObject.GetComponent <FirstPersonController>(); //here is the error
         }
         if (playerController == null)
         {
             Debug.Log ("Cannot find 'FirstPersonController' script");
         }
     }
 
     void Update(){
         if (isInTrigger) {
             if (Input.GetKeyDown (KeyCode.F)) {
                 gameObject.SetActive (false);
                 clicktext.text = "u picked that item up";
                 Invoke ("setTextToDefault", 2f);
 
             }
             if (Input.GetKeyDown (KeyCode.I)) {
                 this.transform.parent = gameControllerObject.transform; //after here I cant move backwars/forward/sideways
                 clicktext.text = "added to int";
                 Invoke ("setTextToDefault", 2f);
 
             }
         }
 
     }
 
     private void setTextToDefault(){
         clicktext.text = "";
     }
     void OnTriggerEnter(Collider other) {
     //    Destroy(gameObject);
     //    playerController.PlayJumpSound ();
         clicktext.text=" f:pick up item.I:add to inventar";
         isInTrigger = true;
         Debug.Log ("jojojo");
     }
 
     void OnTriggerExit(Collider other) {
         clicktext.text="";
         isInTrigger = false;
         Debug.Log ("lol mate u out");
     }
 }
 
Comment
Add comment · Show 5
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 Jinkata · Jul 10, 2017 at 05:59 PM 0
Share

What are your settings for the book collider and rigidbody?

avatar image savanluffy Jinkata · Jul 10, 2017 at 07:20 PM 0
Share

For the book collider

alt text

Rigidbody of the fps:

alt text

unbenannt.png (8.2 kB)
unbenannt2.png (8.7 kB)
avatar image ahorne · Jul 10, 2017 at 06:45 PM 0
Share

Your book object isn't marked static, right?

avatar image savanluffy ahorne · Jul 10, 2017 at 07:14 PM 0
Share

ahorne no it isn't marked static.

avatar image Jinkata · Jul 10, 2017 at 07:19 PM 0
Share

Are you locking the rigidbody's rotation or position?

1 Reply

· Add your reply
  • Sort: 
avatar image
-1

Answer by FortisVenaliter · Jul 09, 2017 at 03:25 PM

Most likely, the collider in the book is blocking the controller from moving. Try setting the colliders to triggers when the book is parented.

Comment
Add comment · Show 3 · 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
avatar image savanluffy · Jul 09, 2017 at 05:18 PM 0
Share

FortisVenaliter how excactly do I do this. I am quite new.

avatar image TheReEvolutions savanluffy · Jul 10, 2017 at 05:48 PM 0
Share

On the collider, check the trigger box. you may also need to change your function to trigger ins$$anonymous$$d of collider.

Edit: it seems that you are already using triggers in your script.

avatar image savanluffy TheReEvolutions · Jul 10, 2017 at 07:16 PM 0
Share

TheReEvolutions my book is by default a trigger. not only when I parent it.

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

73 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

Related Questions

How do I reference the transform component of a gameObject to a script automatically? 0 Answers

Strange movement artifacts when rotating children around parent object 1 Answer

Silly Instantiation Issue 0 Answers

Parent object is getting generated why ?? 1 Answer

Changing the parent of an object gets rid of its parents? 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