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 Larsthedude · Nov 08, 2016 at 11:43 AM · physicsaiprefabsspawningmodels

AI spawns in face-down...

Hi, I'm working on a stealth game where the enemy ai patrols a series of waypoints. My issue is that when the game starts, the AI spawns in face-down instead of right-side-up WITHOUT falling over, if that make sense.

The enemy is just a simple cube with a face on it, and for some reason it doesn't spawn in as I have it set up in the "Scene" view (where they are facing the way they are supposed to.)

Please help me out, guys. I really have been having a hard time with this project and the AI is not making it any easier :(

I can supply the enemy scripts if anybody wants/needs them...

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 aditya007 · Nov 08, 2016 at 11:50 AM 0
Share

$$anonymous$$aybe some script is altering it's transform. Take a look in scripts which have reference to your AI object.

avatar image Larsthedude aditya007 · Nov 08, 2016 at 01:22 PM 0
Share

Hmm... I'm using a script I found for an enemy patrol behavior that relies on Nav$$anonymous$$eshAgent to work, and it seems that it is Nav$$anonymous$$eshAgent that causes the problem.

$$anonymous$$aybe my patrol script is fucky? Thanks...

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by tanoshimi · Nov 08, 2016 at 11:51 AM

The third parameter to the Instantiate() specifies the initial rotation of the instantiated gameobject. Sounds like you need to rotate that quaternion by 90 degrees counter-clockwise around the x axis.

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 Larsthedude · Nov 08, 2016 at 12:03 PM 0
Share

How would I apply that to my code? I do not call for Instantiate in the code already. Should I just throw an instance of it into my start function?

avatar image tanoshimi Larsthedude · Nov 08, 2016 at 01:45 PM 0
Share

You said "the AI spawns in". How exactly are you spawning something without Instantiate?

avatar image Larsthedude tanoshimi · Nov 08, 2016 at 02:01 PM 0
Share

I guess I misspoke. I placed the enemy directly into the game-world, not through using a spawner or spawn script, if that makes sense.

Is that a no-no in gamedev? Should I be using a spawner ins$$anonymous$$d? I'm still new at this, hah.

avatar image
0

Answer by Larsthedude · Nov 08, 2016 at 02:07 PM

UPDATE:

It Seems that applying a NavMeshAgent component break the model, causing it to go face-down. Here's the script I'm using on the enemy that accesses the NavMesh...

 // Patrol.js
 var points: Transform[];
 var destPoint: int = 0;
 var agent: GameObject;


 function Start() {

     // Disabling auto-braking allows for continuous movement
     // between points (ie, the agent doesn't slow down as it
     // approaches a destination point).

     GotoNextPoint();
 }


 function GotoNextPoint() {
     // Returns if no points have been set up
     if (points.Length == 0)
         return;
         
     // Set the agent to go to the currently selected destination.
     agent.destination = points[destPoint].position;

     // Choose the next point in the array as the destination,
     // cycling to the start if necessary.
     destPoint = (destPoint + 1) % points.Length;
 }


 function Update() {
     // Choose the next destination point when the agent gets
     // close to the current one.
     if (agent.remainingDistance < 0.5f)
         GotoNextPoint();
 }

Any Ideas?~

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

how could I spwan a prefab and then have it propelled foward as if thrown? 1 Answer

Making an endless hallway with random objects spawning 0 Answers

When enemy spawns it loses the script settings. 0 Answers

Making an object spawned from a list became a child of the player? 0 Answers

Trouble With Creating A Collection of Enemy Prefabs and Spawning Them 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