Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Kasigawa · Aug 21, 2013 at 06:37 PM · errorenemy

Need help! Enemy follows player with its head!

I have a huge problem. The enemy chases after the player headfirst. I have spent all morning (a full five hours) trying to fix this problem. I have tried to fix it with code, inspector properties, and even by reimporting the model from 3ds max. With the destruction of my ego, I have found no solution; therefore, I am hoping for a miracle that someone has had a similar problem and has found a solution. Here's my code just incase:

 #pragma strict
 var detectedCheck : EnemyVolumeOne;
 var willAttackCheck : boolean;
 var target : Transform;
 var moveSpeed = 4;
 var damping : float = 4;
 
 
 function Update () {
     detectedCheck = GetComponentInChildren(EnemyVolumeOne);
     if(detectedCheck.detected == true){
         transform.LookAt(target); 
 //player looks at me with wrong angle, i have the follow script right, but i need the enemy to follow me correctly.
         
         
         
         //IGNORE
         /*var relativePos = target.position - transform.position;
         var rotation = Quaternion.LookRotation(relativePos);
         transform.rotation = rotation;*/
         
         //transform.eulerAngles = new Vector3(0,transform.eulerAngles.y,0);
         //transform.LookAt(target);
         
         /*var rotation = Quaternion.LookRotation(target.transform.position - transform.position);
         rotation.x = 0;
         transform.rotation = Quaternion.Slerp(transform.rotation,rotation,Time.deltaTime * damping);*/
         
         //transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime *1);
         //transform.Translate(Vector3.up * moveSpeed * Time.deltaTime *-1);
         //transform.position += transform.up * moveSpeed * Time.deltaTime *-1;
         print("he's gonna get you");
     }
 }
Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Kasigawa · Aug 22, 2013 at 03:43 AM

After struggling all day I finally found a solution! Did some digging and found this!

[QUOTE]It still works for me ;) In Max: "Select rotate pivot only" make your rotation so X= 90 and the rest is 0 0 Export with Y as up.

Bingo.

If you have a Biped: ad a root note that has 90 0 0 in rotation and then link the biped to the root so the root becomes parent (Root)

Bingo he stands. Hope it helps.........[QUOTE]

Answer found here: http://forum.unity3d.com/threads/10343-How-to-get-the-XYZ-axis-right-(3DS-MAX-Unity)/page3

Again thanks for the help.

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
avatar image
0

Answer by robertbu · Aug 21, 2013 at 07:27 PM

People on this list have this problem all the time. I'm surprised you were not able to fix it by rotating it in 3ds Max. When your mesh is in Unity with a rotation of (0,0,0), the side you want to be front needs to be looking towards positive 'z'. Typically there are three fixes:

  1. Fix the rotation of the model in 3ds max.

  2. Use an empty game object with your model as a child. The LookAt() script goes on the empty game object. You then rotate the child, visible object so that it is facing positive 'z' when the empty parent object as a rotation of (0,0,0).

  3. Use an additional rotation to 'fix' things.

For an addition rotation you would do your look something like:

 transform.rotation = Quaternion.Euler(-90,0,0) * Quaternion.LookRotation(target.position - transform.position);

I don't know how your model is currently rotated, so the 'Quaternion.Euler() is just a placeholder. You would need to experiment with different values until your enemy is facing the correct direction.

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 Kasigawa · Aug 21, 2013 at 09:27 PM 0
Share

It now falls through the floor. Could you tell me how to change these properties in 3dsmax?

avatar image robertbu · Aug 21, 2013 at 10:05 PM 0
Share

It likely falls through the floor because either 1) you don't have a mesh collider on your object or 2) both the floor and the object use mesh colliders and you did not enable the 'Convex' property of the mesh collider on your object. Convex mesh collider are limited to 255 triangles. If mesh collider against mesh collider is the issue, you could also change the floor to use a box collider.

I don't know 3ds max. The problem of importing from 3ds max has come across UA many times. I suggest a Google of: "3ds max unity3d import".

avatar image Kasigawa · Aug 22, 2013 at 12:48 AM 0
Share

It's good to know that I'm not the only one having this issue. Even though I haven't found a solution, I want to thank you for the help. When I come up with a solution I'll post it to this thread.

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

15 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

Related Questions

Multiple Cars not working 1 Answer

NullReferenceException trouble 1 Answer

Assets/cubeAI.js(2,11): UCE0001: ';' expected. Insert a semicolon at the end. 1 Answer

Unity error "scripts exist in multiple locations" 1 Answer

Why cant I connect to the server? 2 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