Maximize on play issue

I am having trouble with my game. When ever I maximize the game screen, my player does not behave the way its supposed to. I have changed no other setting, so i do not understand how this should affect the behaviour.

Is it because i am on a less than ideal computer?

NOTE: I asked about this on facebook yesterday and someone suggested i try using FixedUpdate() instead of Update(); as you can see this didn’t help, if anything it made the movement slower.

NOTE: Sorry my recording split into to two clips i have uploaded them in order.

After watching your replays you probably have some performance issues, but that I cannot tell until you do this: Try setting the resolution to something other than free aspect and see how it behaves.

Okay so without free aspect on the character moves faster, but maybe still a little slower than when it ran in window mode.

This happens because when you enable free aspect, the bigger the screen, the bigger the resolution, so more pixels are being rendered, your computer will work harder. Try setting the resolution to something your computer is comfortable with.

If you are still having issues with the rocket’s speed, it probably has something to do with the code, Are you multiplying your values to Time.deltaTime to make everything frame independant?

not multiplying the thrust. it wasn’t done in the course video it was just the rotation

Try that and tell me how it goes, if you are still having issues paste your entire code to see what is going on.

okay so that stopped movement of the rocket all together. my code is below. Thank you for helping by the way.

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

public class rocket : MonoBehaviour
{
    Rigidbody rigidBody;
    AudioSource audioSource;

    [SerializeField] float rcsThrust = 100f;
    [SerializeField] float mainThrust = 100f;

    // Start is called before the first frame update
    void Start()
    {
        rigidBody = GetComponent<Rigidbody>();
        audioSource = GetComponent<AudioSource>();
    }

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

    private void OnCollisionEnter(Collision collision)
    {
        switch(collision.gameObject.tag)
        {
            case "Friendly":
                print("Safe");
                break;
            default:
                print("Dead");
                break;
        }
    }

    private void Rotate()
    {
        rigidBody.freezeRotation = true; // take manual control of physics

        float rotationThisFrame = rcsThrust * Time.deltaTime;

        if (Input.GetKey(KeyCode.A))
        {
            transform.Rotate(Vector3.forward * rotationThisFrame);
        }

        else if (Input.GetKey(KeyCode.D))
        {
            transform.Rotate(-Vector3.forward * rotationThisFrame);
        }
        rigidBody.freezeRotation = false; //release control of physics
    }

    private void Thrust()
    {
        float thrustThisFrame = mainThrust * Time.deltaTime;

        if (Input.GetKey(KeyCode.Space))
        {
            rigidBody.AddRelativeForce(Vector3.up * thrustThisFrame);

            if (!audioSource.isPlaying)
            {
                audioSource.Play();
            }

        }
        else
        {
            audioSource.Stop();
        }
    }
}

Sorry I took so long, I had to test this “manually”.

Try changing your mainThrust value to something bigger, 500 starts moving the rocket but a little too slow.

Thank you, that all helps a whole bunch.

so for me to use maximize on play i need to use 16:9 resolution. if i build my game with that size is that going to effect it when the game is built and shared

I’m glad I was able to help you :smiley:

You can set several options for your aspect ratio (and other cool things like graphics) when you build your game:
You can find those options in: Edit - Project Settings - Player

For WebGL is a little different, it’s in the same place but it asks for a specific pixel size canvas instead of an aspect ratio.

So don’t worry about that, work in the resolution that works best for you.

1 Like

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

Privacy & Terms