2D movement issue

Hello, I know i’m probably making this more complicated then it needs to be, but here is the issue:

I want to make a player move with a bit of a weird control scheme. Two vertical axis joysticks used in conjunction for movement and rotation. (using 2D engine right now for simplicity)

Right now I have two child objects with rigid bodies and each move according to the corresponding joystick without issue. My issue is I can’t seem to get them to control the parent no matter how i try, most of the results are the left stick controlling the parent while the right stick still controls the right side child.

for input I have in its own get input method:

leftStickInput = new Vector2(0, Input.GetAxis("Vertical"));
rightStickInput = new Vector2(0, Input.GetAxis("R_Vertical"))

and base movement i have in fixed update:

Vector2 leftMovement = leftStickInput * playerSpeed * Time.deltaTime;
Vector2 rightMovement = rightStickInput * playerSpeed * Time.deltaTime

in the fixed update i was also trying to move the rigidbody2D of each child, thinking this would be easier then putting a separate movement script on each child. Still debating on trying this last part, but either method still leaves me unable to control the parents object movement.

any advice would be appreciated, thanks.

Well, playing around I went and simplified it to this:

void Start()
    {
        rb = GetComponent<Rigidbody2D>();
     }

    // Update is called once per frame
    void Update()
    {
        GetPlayerInput();
              
    }

    private void GetPlayerInput()
    {
        leftStickInput = new Vector2(0, Input.GetAxis("Vertical"));
        rightStickInput = new Vector2(0, Input.GetAxis("R_Vertical"));      
    }

    private void FixedUpdate()
    {
        //move = leftStickInput + rightStickInput * playerSpeed * Time.deltaTime;
        moveFoward = new Vector2(0, 1);
        moveBackward = new Vector2(0, -1);

        if (Input.GetAxis("Vertical") == 1.0f && Input.GetAxis("R_Vertical") == 1.0f)
        {
            rb.MovePosition(rb.position + moveFoward);
        }
        else if (Input.GetAxis("Vertical") == -1.0f && Input.GetAxis("R_Vertical") == -1.0f)
        {
            rb.MovePosition(rb.position + moveBackward);
        }
          
    }

Now i just need to work out how to rotate CW & CCW based on the combination of those two float scale values while still applying movement.
I know i can do something like

 else if (Input.GetAxis("Vertical") >= 1.0f && Input.GetAxis("R_Vertical") <= 1.0f)
        {
            rb.rotation += -mfRot; //rotate clockwise
        }

for rotation but still need to figure out how to get the player moving in the corresponding direction otherwise it will only ever move linear on the vertical axis

You need to post the code where you actually move the objects, the script in each object

Could you post a picture or diagram of your character and how you expect it to move when the left/right joysticks are used independently? From what I can tell, you want the character to move forwards when both joysticks are pushed, but rotate to some extent when only one is being pushed - correct me if I got it wrong.

Right now since each child is a separate physical object, they will move independently of each other. I haven’t used this myself, but it might help with what you’re trying to do: Unity - Manual: Hinge Joint 2D. More information would definitely help though.

that is exactly right. I simplified it down to 1 object while trying to work thru the problem, but even using force or velocity instead of move position, it dosen’t behave the way i’m aiming for. I will add some visual depictions soon as i get back to my main computer later today.

This is one of the concepts I was using as a place holder, but think of the thrusters as separate engines almost like the nacelles you see on the enterprise. The idea being that each throttle controls a side for forward thrust, and counter thrust, this also being ideal way to rotate the ship (like a real life tank or excavator). I wanted the challenge of making a space shooter that did not have direct lateral movement input by the user, but I may add lateral thrusters that can be used on a cool down basis.

5920919--632648--shipTest.png

Right, this paints a clear picture along with the diagram. Since you want the whole ship to behave like a single physical object (no hinges or rotating parts) you could try using the function RigidBody2D.AddForceAtPosition. Adding force from the position of each thruster/counter thruster should produce a rotational force which can be used to turn the ship.

Docs: https://docs.unity3d.com/ScriptReference/Rigidbody2D.AddForceAtPosition.html

I feel like it would be hard for a player to accurately position the ship using just this though, so you might have to add additional logic to help them control their rotation better - maybe lateral thrusters as you mentioned.