- Home /
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.
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.
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.
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.