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 RFLG · Feb 24, 2011 at 11:14 AM · collisiontransformaircraftmanipulation

N00b question: how to implement direct transform manipulation collisions?

Hi everyone.

I'm getting to know unity and I've reached a small bump... On my test project I've implemented a "ship" object (behaves a bit like an airplane), a "track" (plane) and obstacles (cubes).

The goal is to make the "ship" fly around, while not being able to fly across the plane (track/floor) and the obstacles, my intention is to make it crash spectacularly when it collides, forcing the player to avoid them.

The ship's movement is done by direct transformation/manipulation of the ship object, since I wasn't able to find a suitable unity script (like the character controller).

This, as you can imagine, made a mess of my collisions:

-With gravity enabled on the obstacle plus a box collider and a box collider on the ship, the can't fly through the obstacle (sucess!), but it flyies trough the track (fail!).

-If I add a box collider and a rigidbody to the track, and enable gravity, the track "falls down to infinity" (fail!)

-If i set a mesh collider on the ship and activate convex, it will collide with the track, but it will also be "unflyable", since it just keeps spinning out of control like a possessed paper plane...

So my questions are the following:

1-Is there a Unity script I can use to make my movement script? Or should I take the highroad and "expand" the provided Move script (thus solving all my collision troubles because I wouldn't be using transform manipulation anymore)?

2-Alternatively, how can I configure my "track" (plane) object so that it stops "falling to infinity" when gravity is applied and start acting like a proper floor?

3-I've considered that maybe I'm approaching the problem in a very wrong angle (since my work so far is a mashup of unity examples and "creative" code), can anyone provide a recepie(or pointers) for properly setting up the environment that I need (floor, obstacle, flying thing)?

Thanks for helping out a poor n00b :)

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
0

Answer by Joshua · Feb 24, 2011 at 11:43 AM

Let's start with the plane. You want it to stop objects from falling through it but you don't want it to fall itself. Giving it a rigidbody with gravity disabled will do that.

Next make sure that all objects are above this plane when the game starts. If they are partly 'in' or 'through' the plane they will ignore it and all fall through as if it's not there.

Next give both the boxes and the player a rigidbody with gravity enabled. If everything works so far they should now stand on the floor/fall down and hit the floor.

Now go to the boxes and give each one of them a tag to identify them by. Call them 'obstacles' or whatever you'd like.

Now in script you have attached to your player to move him add the function

function OnCollisionEnter (collision : Collision){
 if(hit.gameObject.tag == "obstacle"){
 //the script that makes him do something, for instance makes him spin around the y-axis a couple of times the way you do in mariocart when you're hit. From your question I gather you want something to happen when they collide, this is where you do that
}

Because they are both rigidbodies they should also not be able to pass through each other. Hope this helped, I'm a unity newbie myself as well. :)

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 RFLG · Feb 24, 2011 at 11:13 PM 0
Share

Hi and thanks for the help. Unfortunately it didn't quite work, the settings you've recommend make the box fall through the floor (and also the ship). I had to remove the rigidbodies and replace them by box colliders to prevent the obstacles from going through the floor. As for the ship, adding gravity totally wrecks my "transformation script" but adding a meshcollider to it without gravity seems to help... However this is far from perfect, any suggestions?

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

support not detected collision and Leasehold 0 Answers

How do I increase the size of a GameObject when my firstperson character approaches/collides with it? 1 Answer

Disable a script on collision 2 Answers

"transform" in a static function 1 Answer

Ignore Collision Temporarily 1 Answer


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