Issue with Argon Assault Player Translation after switching to Timeline Movement

I’ve been following the tutorial and have gotten to the timeline implementation section of Argon Assault. When using the circuit, I was able to move my ship to the corners of the screen as intended, but now that I’m using timeline, the WASD keys and joystick imputs simply rotate the model without moving its screen position. However, when I reach the end of the timeline (when forward motion has stopped), I am able to move to the corners of the screen again.
Does anyone know what the issue here could be?

1 Like

Hi Myles,

That’s indeed strange. Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture? Is your player ship (a child of the camera) animated, too?

Hi Nina,
I have checked it against the Lecture code. I’m planning to double check this weekend to see if I missed anything. I believe that only the rig is animated but I’ll have to confirm.
I also reverted back to a previous state with SourceTree and looked for any improper changes I could have made. The strange thing is if I toggle any of the settings on the player rig (camera) while the game is running, it will sometimes allow movement while the timeline is active. Perhaps I’ll submit another video as an example when I return to the project.
I’ve moved on with the course but I would like to solve this just for personal clarity. Thanks for your response!

I’ve checked it again and looking through the lecture code / the videos themselves I’m not sure where I made my mistake. I can toggle the Player Rig animator off and om again to make it run though.
If I can’t figure it out this time, I’ll just restart or move on. Thanks again.

Could you try to update Unity? Maybe it was a bug in your version.

If it’s not, Could you please zip your project, upload it onto the internet (e.g. Google Drive) and share a link here? I’d like to take a look into it. And please delete the Library folder from the zip.

I just made sure my Unity version was up to date and I’m still experiencing the problem. If you do still want to take a look, this link should work I think.
https://drive.google.com/drive/folders/19SWAw0_bTMN-PoPkHs9Z1X5fRkYYrmPF?usp=sharing

Thank you. I’ve looked into your project and noticed another strange behaviour. At the end of the path when you are able to move the ship to the bottom left corner and don’t do anything anymore, it automatically moves to the top right corner of the screen. This indicates that there is probably an issue with your code. When you disable the PlayerController component while the ship is moving automatically, it stops. When you enable to component, it continues moving.

I replaced your ProcessTranslation() method by Rick’s, which fixed the issue. Unfortunately, I have no clue why. When I compared your code to his I was not able to spot any difference apart from the order, which should not have mattered. Maybe I missed something.

    private void ProcessTranslation()
    {
        xThrow = CrossPlatformInputManager.GetAxis("Horizontal");
        yThrow = CrossPlatformInputManager.GetAxis("Vertical");

        float xOffset = xThrow * controlSpeed * Time.deltaTime;
        float yOffset = yThrow * controlSpeed * Time.deltaTime;

        float rawXPos = transform.localPosition.x + xOffset;
        float clampedXPos = Mathf.Clamp(rawXPos, -xRange, xRange);

        float rawYPos = transform.localPosition.y + yOffset;
        float clampedYPos = Mathf.Clamp(rawYPos, -yRange, yRange);

        transform.localPosition = new Vector3(clampedXPos, clampedYPos, transform.localPosition.z);
    }

The issue with the ship not moving during the timeline animation is not fixed yet. I added a Debug.Log to the method. The messages appear meaning that the method gets called.

I know that Unity does not like it when you animate and move the object via code at the same time. For this reason, I checked the animation. Unsurprisingly, the position of the Player Ship is animated.

image

image

I removed the property. Now the ship is moving as expected. :slight_smile:

Thank you so much! I don’t know how I didn’t catch that Player Ship : Position property but that was clearly the biggest issue.
Also, I had noticed the ship pulling to the top right corner since the begging and knew it was tied to the control speed. If I’d set it to anything other than 0, it would make the ship automatically fly in the x and y direction.
I think the reason was that the code in the material for player translation is:
float xOffset = xThrow * controlSpeed * Time.deltaTime;
float yOffset = yThrow * controlSpeed * Time.deltaTime;
Whereas I had typed:
float xOffset = xThrow + controlSpeed * Time.deltaTime;
float yOffset = yThrow + controlSpeed * Time.deltaTime;

As of right now these small changes seem to have me most of the way back on the right track. I appreciate your help!

Dear me, it took me around one minute to spot the difference in your answer. The * and the + look so similar. No wonder I didn’t see it when I compared your code to Rick’s. I’m glad the game works now as intended.


See also:

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

Privacy & Terms