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 ODNSEV7N · Dec 07, 2013 at 01:13 PM · align

How would I align edges on instantiated prefabs?

Hey all, I have been wanting to make a track maker as a feature in my game, I have the sections that align perfectly as you can see in the pic.

I wanted to know how I would either weld each of the vertices so they snap together, or more realistic, snap the edges together.

I will have it so the user can tap a button, and it will automatically spawn the next track section aligned with the last one.

Any ideas?

Cheers, Tim.

alt text

weld.jpg (505.3 kB)
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 applejuices · Dec 07, 2013 at 02:28 PM 1
Share

Ive don't this befor, basically, when you instantiate the object (object instantiation has to be a var) Change the transform to snap it, basically, instantiate, make a var that gets in transform, then make a var, in update, make it so it gets old war, puts it in new var, and rounds it to a unit.

avatar image Fornoreason1000 · Dec 07, 2013 at 02:42 PM 1
Share

when you make the track pieces in your 3d editor take not of its size, i make all my models tile-able because they conform to there size, e.g each models s size are multiple s of 5 , for tracks i would say 20;

lets say you want to spawn a piece that is 20x20 units and the first pieces's transform is [0,0,0] and its size is also 20x20. the position for the new piece would be [20,0,0] if it goes right, [-20,0,0] if it goes left, [0,0,20] if it goes forward and [0,0,-20] if it goes backwards.

avatar image ODNSEV7N · Dec 07, 2013 at 03:10 PM 0
Share

heheh I didn't think of modeling them like textures.

So..all the user will need to do is rotate 90 degree increments :)

I tested it in photoshop with pretend objects (as pictures of corners), and works great thanks!

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by jtok4j · Apr 19, 2019 at 05:04 AM

5+ years and no answer... Rats... I was hoping for the answer to this too... Keep On Creating!

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 DarkShadowsX5 · Apr 19, 2019 at 06:37 AM

6 years later... (a new player has appeared!)

One way is to place child empties at the center edge of each end of the track and align them by using the empties transform coordinates. then you can lock it onto the empty Objects position.

To make a snap feature you could either raytrace for the nearest empty within x distance or more simply use a temp sphere object for collision detection then fixate the one you moved to the others position.

@jtok4j
@ODNSEV7N ~everyone else who wants the general idea.

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 Bunny83 · Apr 19, 2019 at 01:53 PM

Unity always had the vertex snapping feature as far as i can remember (and that goes back to Unity 2.6 in 2011). Just select an object in the sceneview. Now there are two options. Grab the pivot of the object then press and hold "v" to snap that pivot point to another vertex of another object.


However the more useful feature is to first press and hold "v". Now you can actually "grab" a vertex of the selected object and snap it to another vertex.


Note that when you search for "unity vertex snap" in google the first hit is the Positioning GameObjects documentation page in the manual which mentions vertex snapping at the bottom. There are also several videos (like this one from 2013 or an official one from Unity) which explain how vertex snapping works.


The search took me about 10 seconds (since i'm not that fast on the keyboard). Searching for information requires actual searching.

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

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

Related Questions

set guiText component to bottom left corner of screen in IDE 1 Answer

Bullets not orienting properly 0 Answers

Align 2 objets edge to edge 1 Answer

How can I align Axis? 0 Answers

Snapping To A Grid - Trouble With Mathf.Round 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