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 Deikkan · Jun 29, 2010 at 10:43 AM · colliderenemyfollow

Enemies fall through floor when chasing player.

I have some scenery models with mesh colliders attached, along with enemies placed ontop of them. In my current AI code for the enemies, they chase the player by moving to the players position value, as described below.

function ChasePlayer() { //print ("Chasing Player"); animation.CrossFade("Walk", 1); dir = target.transform.position - transform.position;

 dir = dir.normalized;
 transform.Translate(dir * speed * 5 * Time.deltaTime, Space.World);

}

However, when the enemy chases the player up a hill, they walk through the floor ignoring the mesh collider, and fall to their death. Each enemy has a character controller and a platformer controller attached.

The game is a 2D sidescrolling platformer if that helps.

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

1 Reply

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

Answer by spinaljack · Jun 29, 2010 at 10:58 AM

Couple things you could do:

  1. Don't edit the bot's transform position directly, it is likely you're pushing them into the terrain, use velocity or give the bot a proper move script like the player has
  2. Change the bot's collider if it's a mesh collider as they tend to get stuck more easily
  3. Increase the physics calculations per frame to try and catch collider penetrations (this doesn't solve the source of the problem)
  4. Add box colliders to the terrain if you're using mesh colliders for the terrain to "reinforce" them
Comment
Add comment · Show 1 · 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 Deikkan · Jun 29, 2010 at 11:20 AM 0
Share

Thanks for the reply.

The reason I don't use rigidbodies is that the enemies behave in ways that do not fit the game. I felt that the problem was with using transform.Translate() to move the player, but I cannot apply a velocity since it does not have a rigidbody. I'll see if I can use Simple$$anonymous$$ove ins$$anonymous$$d and find out if that fixes the problem.

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

No one has followed this question yet.

Related Questions

Problem with Flashlight in Horror Game 2 Answers

Problem with a monster (he follows me backwards) 1 Answer

How to handle multiple colliders for one enemy and bullet. 3 Answers

How i make the NPC friend stop following me and start to follow the enemy when he is near???!!! 0 Answers

How can I make my enemy stay on the ground and collide with other objects? 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