- Home /
Move 3D Cubes with mouse
Hi
I have a grid based game, and I want to be able to click and drag one cube in direction left to right. If there are other cubes on the same row, then those cubes will be dragged with it. I attached an image, where block #2 pushes block #1 when dragging to left with mouse one unit.
The current way I have it working, is with transform object to mouse. When dragging too fast, it goes through block. Would using AddForce be a better alternative? Perhaps translate?
Any suggestions will help.
Thanks, Chris
Answer by PAHeartBeat · Feb 11, 2017 at 10:18 AM
Hi,
Uses of AddForce is not good option, it will work but you will lost control plus you have to add Physic system for that.
As you said the game is grid based. so just use grid address of the box (row, column) or (x,y) from two-dimensional array. it will give better control to you over object, it position and lot more things. once you got grid address of box you can move update box in same row.)
Thanks for your response. I just added an image to explain myself better. Are you saying to use object.transform.position on mouse drag? Currently it works but it makes block go through object moving it too fast.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Smooth out character movement? 4 Answers
Distribute terrain in zones 3 Answers
destroying game object in a specific transform 2 Answers
Inconsistent jump height 1 Answer