I’ve been working on prototyping a star fox like movement system where the player only controls the x and y movements of a ship within a set boundary while the ship moves along a set path. I currently have a ship the moves in one direction while the player can control its position on screen. Where I’m having issues is how I would go about getting this whole rig to move on a preset path. I have no doubt that I could solve this in some complicated round-about manner but I wanted to know if there is some straight forward solution that could save me a lot of wasted time. Any hint or push in the right direction would be great. Thanks.
Essentially: use the transforms local axes to do the translation and use your path to determine the orientation. Something like
//get your offset direction
Vector3 direction = Vector3.zero;
if(goRight)
direction += transform.right;
else if(goLeft)
direction += -transform.right;
if(goUp)
direction += transform.up;
else if(goDown)
direction += -transform.up;
//add your forward movement
Vector3 zDirection = (Vector3)nextPositionOnPath - (Vector3)currentPositionOnPath;
direction += zDirection.normalized;
transform.position = transform.position + direction*speed*Time.deltaTime;
transform.rotation = Quaternion.LookRotation(zDirection);
Just add your boundary check in there. It’s not a final solution but it should get you started