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
1
Question by JudgeDredd · Jul 14, 2014 at 10:06 AM · gameobjecteditormousemovesnapping

Mouse Snapping?

I was wondering how to move a gameobject to the moues but snap it like you can do in the unity editor when moving objects. I currently just move the objects straight to the mouse position and I want it to snap to every 32 pixels like you can do in the snapping grid for the editor. I wanna move the GameObject in-game and it's 2D view.

Comment
Add comment · Show 2
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 NoseKills · Jul 14, 2014 at 03:18 PM 0
Share

Are you using perspective or orthographic camera ? Perspective makes everythimg a bit harder because 32 pixels will be different depending on how far it is from the camera.

avatar image JudgeDredd · Jul 14, 2014 at 09:07 PM 0
Share

It's orthographic using Unity's 2D tools

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Major0 · Jul 15, 2014 at 12:14 AM

So to rephrase your question, you want to snap the object in the editor towards the mouse but rather gradually than straight away. And you're talking about doing that in the editor NOT in-game.

Why do you even want to do that if you have other ways to insure fine tuning of placing objects in the scene? i.e. :

Normal Snap:

Select your gameobject.

Choose transform tool.

Hold CTRL & move in any direction

Vertices Snap

Select your gameobject.

Choose transform tool.

Hold V.

Hold CTRL

Move your mouse to another vertex (Any surface/edge/point of any gameobject)

In case if you required a custom snapping motion and my answer was insufficient to you, then PM vexe and hopefully he'll have a sufficient one.

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 JudgeDredd · Jul 15, 2014 at 07:19 AM 1
Share

No I wanna get that snap effect in-game. Basically I have a gameobject that moves with the mouse in-game but I want it to be snapping to a grid exactly like how the editor does it but I gotta code it in C# and I don't know how to do that.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Make the gameobject flip to the direction it is being dragged to? 1 Answer

GUI Remove focus from an editor text field when clicking elsewhere. 2 Answers

Make an Object Animate Up In The Update Function 2 Answers

My object wont move when I use transform.translate. 2 Answers

Moving GameObjects with mouse and check contains 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