i hav a cube gameobject of which i need to change the front position or head or its tip.i use a transform .foward function on the object like this:-
transform.position += transform.forward * Time.deltaTime * speed;
the problem is that the cube moves along the middle of one of its sides(fig-1)and not along one of its corners (fig-2).please help.
you could either Change the direction where to move your cube, or Change the direction.
What your code does is move the cube along it’s Forward direction (Z-Axis) which Points to one of its sides. Now you could Change that Forward direction to Point somewhere else and Keep your move code like this:
or you Keep the directions of the cube (Forward, Up and Right) but Change your move code to whereever you want it to move to like that:
transform.Position+=new Vector3(0,1,1) * Time.deltaTime * Speed;