Ship zooms off after it flys

My ship is zooming off after it flies, not before - and I can’t make it move even a little bit when it is flying along the track. (See Video) . After I made the video, I added the newYPos script and it just stays at the end, no zooming offscreen - but it still can’t move around when I click ASDW.

https://youtu.be/ZM9MLI6fKvc

Here is my code as well:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerControls : MonoBehaviour
{
[SerializeField] float controlSpeed = 10f;

// Update is called once per frame
void Update()
{

    float xThrow = Input.GetAxis("Horizontal");
    float yThrow = Input.GetAxis("Vertical");

    float xoffset = xThrow * Time.deltaTime * controlSpeed;
    float newXPos = transform.localPosition.x + xoffset;

    float yoffset = yThrow * Time.deltaTime * controlSpeed;
    float newYPos = transform.localPosition.y + yoffset;

    transform.localPosition = new Vector3
        (newXPos, newYPos, transform.localPosition.z);

}

}

1 Like

HI,

Did you by any chance set your ship position in the timeline instead of the player rig?

Maybe… that would make sense… Do you know a way to fix that if I did?

You will have to delete the animation track and recreate it with the correct game object. The child, which you move via code, must not be animated.

1 Like

I think -if this is the case at least- if you remove the positions you set for the ship,
it should be free to move again with the controls.
Your playerRig also moves, you could leave those, i think it should work then.
But if it does not, you can better wait till Nina sees your question, im just a student too.

1 Like

Thank you, I’ll try that and what Nina said.

Thank you! I’ll try this out.

I think it’s working better now. I went back to the previous videos and took away the Animated Player Rig from the Master Timeline. I don’t know how I made it parent weird, but after re-doing the keyframes it’s working better. Sometimes I have to click on the game play button twice (like in the video) to make the camera align correclty, but other than that it seems to be working. I re-positioned it too for better flying, not going through trees as much, so I’ll go back and re-work the enemy placeholder movement too. Thanks to you and @RustyNail for the suggestions.

1 Like

Well done, Daisy! :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms