Still working on my Star Fox clone and am changing up the camera a bit.
The problem I keep having is my Ship gets locked in the middle of the screen and can't move while its parent (spinMe) is still moving.
I'm working with rigidbody-ception here I have a rigidbody with in a rigidbody. Both of them move up, down, left, and right.These two are called spinMe and Ship.
In this version the player is able to move until they reach the end of the screen.
What I'd like to do is have the camera move slightly as well to help Ship cover more of a bases and help with perception. Star Fox did this as well.
So spinMe pulls Ship around with it but for some reason that keeps Ship from moving independently while being moved around by spinMe. Only when spinMe can't move any further Ship will move.
So I guess I would like to know is why can't I get my Ship to move at the same time as spinMe.
So this is the main chunk of the code for spinMe
Vector3 movementy = transform.TransformDirection(Vector3.up * Input.GetAxis("Vertical") * turnSpeed); Vector3 newPos = transform.position + movementy; Vector3 offset = newPos - Midpoint.position; transform.position = Midpoint.position + Vector3.ClampMagnitude(offset, radius); Vector3 movementx = transform.TransformDirection(Vector3.right * Input.GetAxis("Horizontal") * turnSpeed); Vector3 newPosx = transform.position + movementx; Vector3 offsetx = newPosx - Midpoint.position; transform.position = Midpoint.position + Vector3.ClampMagnitude(offsetx, radius);
And this is the movement for Ship
Vector3 pos = Camera.main.WorldToViewportPoint(transform.position); pos.x = Mathf.Clamp01(pos.x); pos.y = Mathf.Clamp01(pos.y); transform.position = Camera.main.ViewportToWorldPoint(pos); Vector3 moveDirection = new Vector3(turnSpeed * Input.GetAxis("Horizontal"), turnSpeed * Input.GetAxis("Vertical"), 0); moveDirection = transform.TransformDirection(moveDirection); rb.MovePosition(transform.position + moveDirection);
I've tried this a variety of different ways and I believe this is my best chance of getting this working.