• 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 ronanzer0 · Feb 23, 2015 at 12:53 PM · physicstrackracemagnetmagnetic

Magnetic Race Track? How to stick to a tubular track?

So in F-Zero which is what my game is based on, you go around these 'tubular' race tracks, like this: https://www.youtube.com/watch?v=9k6kvFg5Ih8#t=53 (0:53)

You can freely race around the cylinder, whether it be from the top, sides, or bottom and you totally stick to it like a magnet. Of course it's hovercars that hover slightly above the track, but still.

I've tried to recreate that with the cylinder GameObject in Unity, and scripts.

Most scripts I've tried were seen in this thread: http://forum.unity3d.com/threads/how-in-the-world-were-the-physics-in-f-zero-x-done.204747/

I've also browsed unity answers forever, this has been getting me for days since I need to figure out a reliable way that works with any type of gameobject, any type of car and isn't buggy as heck. I've even tried to combine various scripts.

Comment
Add comment · Show 8
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 Nymisu · Feb 23, 2015 at 02:06 PM 0
Share

Do keep in mind that these games do not actually utilize physics either on the sole axis or in its entirety when in contact with the track, but rather simulate it. The unity analog is that the tracks have a series of rotated box-collider entities upon which' touching disables physics/gravity/whatever on the relevant plane, and forces the object to keep it locked within distance from the closest, possibly raycasted collision box it can find.

There are more advanced ways of doing this, but this is probably the easiest way, if not the cheapest.

There's also the "raycast collider" in unity, try experimenting with that.

avatar image melkorinos · Feb 23, 2015 at 02:09 PM 0
Share

How about adding a force to the transform.up while you are ridding the tube? Obviously not the best solution but might work and its simple enough. Lets us know if you do manage to achieve this, cause its cool :D

avatar image Sethhalocat · Feb 23, 2015 at 02:56 PM 0
Share

You can make it so the map turns ins$$anonymous$$d of the character

avatar image melkorinos · Feb 23, 2015 at 03:36 PM 0
Share

@Sethhalocat : how would you do that exacly? can you be more specific, sounds interesting

avatar image ronanzer0 · Feb 23, 2015 at 06:26 PM 0
Share

@Sethhalocat I eventually plan on making this game at least 4 players online, maybe more, so that's definitely not happening.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tswalk · Feb 24, 2015 at 04:22 AM

if you were dead-set on using physics,...

i would test:

  • turning gravity off on objects and relying only on forces (like being in space.. zero 'g').

  • apply a directional force from the bottom of the 'hover craft' toward the surface normal of the track (tube)

  • use a 'forward' force on the hover craft to propel the object in that direction

you may also look at using physics joints between the hover craft and an empty gameobject that sticks to the surface of the track.. so if players are hit hard enough, it breaks and they go careening off ... just some thoughts, but I think this could be done with physics alone.

like you said, like a magnet.. gravitational forces are weaker compared to magnetic... so turn them off, and just use the idea of forces to control stuff.

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 ronanzer0 · Feb 26, 2015 at 05:35 AM 0
Share

surface normal...? also how would i get it to rotate around, thats the main thing im looking for is rotate around if you drive slightly down the track ins$$anonymous$$d of completely forward.

avatar image tswalk · Feb 27, 2015 at 03:53 PM 0
Share

one simple example is using colliders:

     void OnCollisionEnter(Collision collision)
     {
         foreach (ContactPoint contact in collision.contacts)
         {
             Debug.DrawRay(contact.point, contact.normal, Color.red,50);
         }
     }

... have a box collider below the ship and use a static collider (based on mesh of the tube) for the track. You may be able to pull the contact.normal vector and use this to apply a "force" on the rigidbody of the ship.

you can apply a constant force or other types to the player based on the controller movement.

avatar image ronanzer0 · Mar 07, 2015 at 02:23 AM 0
Share

i dont get it

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Magnetic ball 1 Answer

How do I make use of an Import and make use of a downloaded race track? 2 Answers

Magnetic object to make coins move to object 2 Answers

Whats the best way to colour? 1 Answer

Creating a magnetic vehicle (like F-Zero) (2) 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges