Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 YetiStudio · Mar 15, 2018 at 09:25 AM · navmeshnot workingupdate functionignoreruntime-generation

Function Update is not being called when object have a parent

Hi,
I'm getting a bit stuck with my AI system and I encounter a really weird problem, I've been using Unity for many years but I never encounter this.

Basically, I'm making a procedural game where almost everything is made during runtime including navmesh and Spawners : alt text

My spawners have a script attached which allows them to spawn the animals, this script works perfectly fine, here are the two main lines used to spawn AI :

GameObject randomAnimalPrefab = Instantiate(holderScript.animalsPrefab[3], new Vector3(transform.position.x, transform.position.y + 0.2f, transform.position.z), Quaternion.identity);

randomAnimalPrefab.transform.SetParent(transform);



As you can see I instantiate my animal (animalsPrefab[3]) and I then attach the spawned object to the transform of this script which is "Spawner(Clone)" on the last screenshot.

Now here is the problem : My Animals (let's say AI) have a script which allows them to move on the terrain based on a runtime bake. The script is a bit long but here is the important line which is in the Update function :

transform.position = Vector3.MoveTowards(transform.position, target, movementSpeed);

In theory, this line is supposed to move my AI to a randomly generated target on the terrain (don't ask why I'm not using SetDestination with agent, the proceduraly generated terrains hardly allows that). The problem is that this line and the whole Update function is not read when my AI has a parent.

BUT

When I move my AI out of the "Spawner(Clone)" parent it works perfectly fine. Here is a video to explain this more in details :

Video example


Notes :
• All my scripts derive from MonoBehaviour
• All the parents objects are active so the Update function should be running
• I used a Debug.Log in the update function but it is never read as long as my AI has a parent.
• I tried to use "localPosition" instead of "Position" without success but the problem is maybe linked to that

TLDR : My Update Function is never called when my Object has a parent.

sans-titre-1.jpg (24.2 kB)
Comment
Add comment · Show 2
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 hunabku94 · Mar 03, 2020 at 08:30 AM 0
Share

None can help please ?

avatar image tormentoarmagedoom · Mar 03, 2020 at 03:59 PM 0
Share

If you post the code maybe... we are not magicians.

PD: beeing a child or a parent is irrelevant for execution of Update()

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

132 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

Related Questions

orbit gravity, 0 Answers

Runtime Navmesh only getting edges of mesh 0 Answers

Creating NavMeshAgent types at runtime 0 Answers

Random.Range kepps returing the same value 1 Answer

how to properly upload a game into facebook? 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