3D Grid Based Movement
using this to create a grid for my cube
[ExecuteInEditMode]
public class EditorSnap : MonoBehaviour
{
[SerializeField] float gridSize = 10f;
void Update()
{
Vector3 snapPos;
snapPos.x = Mathf.RoundToInt(transform.position.x / gridSize) * gridSize;
snapPos.z = Mathf.RoundToInt(transform.position.z / gridSize) * gridSize;
transform.position = new Vector3(snapPos.x, 0f, snapPos.z);
}
}
Using this to move forward
transform.position += new Vector3(0f, 0f, 10f)
works fine triggering off a keydown. Moves 1 grid space at a time.
however when I try to add
transform.position += new Vector3(0f, 0f, 10f) * Time.deltaTime * speed
in the update method it doesn't do anything. just sits there unless i crank the speed variable way up, then it flies off the screen.
Halp?
Comment
Your answer
Follow this Question
Related Questions
3d grid/matrix inside a mesh 1 Answer
How do I obtain smooth movement of a 3d object on an int grid? 0 Answers
How to check if object is inside another 1 Answer
Grid/TileMap rotation not affecting child GameObjects? 0 Answers
Player Controls For Restricted Directional Movement, but those things vary... 0 Answers