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 Herve_Simard · Jul 03, 2012 at 07:52 PM · rigidbodyc++iskinematic

enemy using "isKinematic" stacks

Hi everyone,

I'm coding a script in C#. I'm building a tower defense and I'm having a huge issue here. My enemies spawn from a spawnpoint and goes all their way to where they are supposed to go. When they get there, actually, I have to make them "stop". So I'm using the "isKinematic" option coming with the rigidBody.

But my enemies stacks one atop the other. I'd need them to mass around, but stay put in y, only move in x.

Any solution anyone? Time grows short...

Comment
Add comment · Show 3
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 GC1983 · Jul 03, 2012 at 07:54 PM 0
Share

$$anonymous$$aybe try making their colliders really talk so they cant shift above one another?

avatar image Herve_Simard · Jul 03, 2012 at 07:58 PM 0
Share

Works for the first one, but every enemy following still stacks...

avatar image nventimiglia · Jul 04, 2012 at 12:05 AM 0
Share

$$anonymous$$ind of hard without any code.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Wiki

Answer by Linus · Jul 04, 2012 at 05:19 AM

Hard to help as it is a big topic, and very little information to go on.

Suggest you read up on path finding and crowd simulation. There is a good video about it here http://www.youtube.com/watch?v=0nQnbxCiWWE

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 asimov · Jul 04, 2012 at 12:23 AM

If in the Editor you can just uncheck IsKinematic and just use the Rigidbody constraints, tick the position and rotation axes you want to restrict.

More specifically in code (c#), you can change the Rigidbody constraints with something like the following.

 // To constrain the Y-axis position
 private RigidbodyConstraints ConstrainYmovement;
 
 ConstrainYmovement = RigidbodyConstraints.FreezePositionY; 
 
 //and when setting it to your Rigidbody.
 
 transform.rigidbody.constraints = ConstrainYmovement;
 
 // Set back to default (no constraints)
 private RigidbodyConstraints DefaultContriants = RigidbodyConstraints.None;
 
 transform.rigidbody.constraints = DefaultContriants;



Hope that helps.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Get all child not working? 1 Answer

How to get collision point when using onTriggerEnter 5 Answers

Point of contact on other object in OnTriggerEnter 1 Answer

Rigidbody not responding after toggling isKinematic 2 Answers

Under what circumstances are compound colliders created? 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