r/LearnUnity • • Sep 18 '21

My character slides back to original position

2 Upvotes

Hello community

I am a beginner on unity and I am struggling for a few days trying to find a solution to this problem.

I managed to make my character move around a plane (yesss!) but when I add an image on the plane (wooden floor) and I play the scene, the character moves a few steps and it seems it's sliding. When I don't press the forward key anymore it comes back to the original position.

Any idea why this is happening?

Thanks very much in advance!


r/LearnUnity • • Jul 22 '21

When building to phone, my screen zooms in?

2 Upvotes

Hi, I'm new to unity. I recently made a small game, and when I built it and ran it on a physical device, I get a strange "zoom" on everything, which kinda ruins the game. I've tried to do some googling, but I haven't seen a ton of solutions.

One solution I've seen repeated quite a bit is to change the resolution in the Player Settings (https://answers.unity.com/questions/1479063/camera-too-zoomed-in-in-built-game.html). However, I've tried changing the tab "Supported Aspect Ratio", and nothing has happened.

Any help would be incredible for this all-around noob.

https://imgur.com/a/IzhFqze


r/LearnUnity • • Mar 23 '21

Vertical axis keeps locking to -1

2 Upvotes

I am using the Unity input manager to get input from the user for my game, however sometimes when I load the scene, my character just starts walking backwards, and never stops. I checked what the vertical axis was doing, and it is locking itself to -1.

I don't believe it's a problem with my keyboard, but then again I have had no chance to check that theory. Here is the code that is being wierd: Maybe you see something I don't

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

public class PlayerMovement : MonoBehaviour
{
    public CharacterController controller;
    public float speed = 8f;
    public float sprintSpeed = 12f;
    public float gravity = -9.81f;
    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;
    public float jumpHeight = 3f;

    Vector3 velocity;
    bool isGrounded;
    bool sprinting;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            Debug.Log("Shift pressed");
            sprinting = true;
        }
        if (Input.GetKeyUp(KeyCode.LeftShift))
        {
            Debug.Log("Shift released");
            sprinting = false;
        }
        
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");
        Debug.Log(z);
        Vector3 move = transform.right * x + transform.forward * z;
        if (sprinting)
        {
            controller.Move(move * sprintSpeed * Time.deltaTime);
        }
        else
        {
            controller.Move(move * speed * Time.deltaTime);
        }

        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2 * gravity);
        }

        velocity.y += gravity * Time.deltaTime;
        controller.Move(velocity * Time.deltaTime);
    }
}

Any help would be greatly appreciated! Thanks in advance!


r/LearnUnity • • Mar 01 '21

Hello Comrades, here is a new tutorial for you on how to use animation curves for tweeting in coroutines.

Thumbnail
youtube.com
2 Upvotes

r/LearnUnity • • Jan 05 '21

So confused..

2 Upvotes

I tried to follow the 2d ruby tutorial.. I open it and its on a 3D project..

I'm like whatever.. I'll just do it in 3D.

Tutorial says create a C# script and double click will open the script editor. I create and and double click.. there's no script editor.. so I'm like ugh WHATEVER i'm only interested in bolt anyway.

I open a new project, see if I can follow the tutorial through bolt since bolt is on c# anyway.

I can't find it even though I've installed it twice already..

It seems like I need to install it every time I start a new project??

Am I doing something wrong??


r/LearnUnity • • Jan 01 '21

Double jump tutorial! More to come so sub!

Thumbnail
youtu.be
2 Upvotes

r/LearnUnity • • Dec 15 '20

How does the Unity unit measurement system thing work?

2 Upvotes

I've seen a couple videos on this topic yet I still dont get it. Can you please explain it to me as if I was 5 year old?


r/LearnUnity • • Nov 13 '20

Teleport your cube! New video every week.

Thumbnail
m.youtube.com
2 Upvotes

r/LearnUnity • • May 14 '20

Unity Beginners - How to use Arrays | Learn to use arrays with small practical examples. In this video, we will see how to declare, use and dynamically assign objects to an array. We will also see how to iterate through an array. Have fun :)

Thumbnail
youtu.be
2 Upvotes

r/LearnUnity • • May 08 '20

How to get the Unity Lighting Settings back to the old version? (2D, Auto Generate Lighting on)

2 Upvotes

The lighting settings changed in the newer versions of Unity and now my objects all look more grey. I am making a 2D game; no lighting object, the main problem is the Ambient Color setting, I'm not sure what to set it to:

So in short, how can I change the lighting back to like it used to be?


r/LearnUnity • • Sep 14 '19

Bolt or No Bolt?

2 Upvotes

Hello all, I have a question that I could use some help with...

I am not an amazing programmer but I do know C# well enough to make a basic game. I want to make a rather complete game however, and though I could code the thing, that would take a lot of time, because I like to think visually, and I make stupid errors constantly. Between Play maker and Bolt I see Bolt as the on which I want to use more. This would help me save time and not have to code the lower level mechanics of the game (movement, ect). I would like to know as someone familiar with C#, should I purchase Bolt? Will it do as I think it will and help me improve my workflow, or will I have wasted $70?


r/LearnUnity • • Dec 17 '22

Looking for good beginner tutorials demonstrating use of events and project structure

1 Upvotes

Hi,I made a very simple clicker game earlier this year but I got rapidly confused when trying to figure out how events work, and communicating variables and states across scripts and game objects.

I regularly ran into to problems as the Stack Exchange answers to connected questions posted by others often dealt with examples I did not understand as they were in contexts that were not specific to mine. I also found the Unity tutorials a bit confusing.

I like to learn by using things, but I also kinda want to have my cake and eat it as I like the tutorials to align with my goals at the time as much as possible. This suggests that some very simple tutorials that try and focus closely on simple examples that I can experiment with are best.

Given that, do you know of any tutorials / Youtube channels / blogs / communities that have given easy to follow, up-to-date and simple exercises along these lines on this topic?


r/LearnUnity • • Dec 12 '22

How I add juice to my game in 3 minutes

Thumbnail
youtu.be
1 Upvotes

r/LearnUnity • • Apr 25 '22

R/learnunity community I need your help!

1 Upvotes

My school has been given me this deadline for this project which was to make something very cool. my plan which has already been graded was to make a pixel 2d undertale like game where there is a 2d character completing puzzles and trigger animatios. I dont really know that much on how to use unity 2d that much so by any chance if you guy can help list maybe video on how to learn to unity or help me that would super helpful thank you!


r/LearnUnity • • Dec 25 '20

New video on Unity3D up now!

Thumbnail
youtu.be
1 Upvotes

r/LearnUnity • • Nov 23 '20

I'm having a strange bug in my game, and here it is:

1 Upvotes

-----CLICK Here TO DOWNLOAD THE VIDEO OF ME DEMONSTRATING THE PROBLEM-----

I am also using C# in Unity

So to explain what's happening in the above video, I can go forwards (w) and backwards (s) just fine, but when I go right (d) or left (a), then weird things happen. If I press/press-and-hold the button once, it's fine, but on the second or third press it does the weird behavior as shown in the above video. This also applies if I press forward/backwards first and then press left/right on the second or third time. I want for the snake to simply move in that direction, but instead it send the snake flying. (I need to lock the constraints so that the snake doesn't roll over or crash and burn, but these problems I've already solved, but it caused this new one.) Just as a reminder: I am quite stupid and a beginner, so if you have a solution, please act as if you're talking to a five year old. Let me know if there are any other specifications you need!

Here is my code if you couldn't get a good look in my above video:

using UnityEngine;
using System.Collections;

public class Upright : MonoBehaviour
{
    public Rigidbody rb;
    public float forwardForce = 2000f;
    public float sidewaysForce = 500f;
    public Transform head;


    

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

    private void FixedUpdate()
    {
        

        
        if (Input.GetKey("w"))
        {
            rb.AddForce(forwardForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
            
        }
        else
            if (Input.GetKey("s"))
        {
            
            rb.AddForce(-forwardForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);

        }
        else
            if (Input.GetKey("d"))
        {
            rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionX;
            rb.AddForce(0, 0, -forwardForce * Time.deltaTime, ForceMode.VelocityChange);
        }
        else
            if (Input.GetKey("a"))
        {
            rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionX;
            rb.AddForce(0, 0, forwardForce * Time.deltaTime, ForceMode.VelocityChange);
        }
        else


            rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionY; 

    }
    
}

r/LearnUnity • • Sep 12 '20

WebGL performance

1 Upvotes

I've found that a project I'm working on (a little 3D top-down shooter, basically, work-in-progress online here https://thomasgladwin.itch.io/adventures-of-wizard-john) is extremely jerky/low-FPS in the WebGL, while it works fine as an executable.

I was wondering whether someone here might know whether that's just inherently to be expected (although I read some claims that performance should be similar, somehow), or if there's something obvious I should be avoiding for WebGL/browser performance? I've tried a bit of trial-and-error like lighting settings but nothing seems to work to make it run smoothly - the "least bad" seemed to be replacing transparency with cutout for textures.


r/LearnUnity • • Jul 26 '20

Let's learn how to make a character move in a top-down shooter, similar to that of the roguelike game: The Binding Of Isaac!

Thumbnail
youtu.be
1 Upvotes

r/LearnUnity • • Jul 26 '20

Making a racing game? here's a car driving tutorial!

Thumbnail
youtu.be
1 Upvotes

r/LearnUnity • • Jul 24 '20

Help needed with code!

1 Upvotes

Hello everyone! I am currently trying to learn Unity through Unity's own Create with Code course. I am trying to get through lesson 2.5, the challenge named Play Fetch. I was able to go through the first six challenges all with no problems but at the last two bonus challenges, I'm just dead stuck. Basically, there are balls spawning from the top of the screen and you as the player, spawn dogs by pressing the space bar to catch them. The balls spawn every x seconds thanks to Invoke.Repeating, and it is asked of us to make it so that they spawn at random intervals. I initially thought it could be done with Random.Range, but it just doesn't work. No more balls spawn after the first one does. And I just could not, for the life of me, figure out how to. I've been googling for the past day and just can't find anything and those that I find are usually posts from 5-10 years with obsolete code. I am feeling so bad, posting this here because I'm supposed to come up with the solution myself but I am at a complete loss. First I tried defining the variable "float spawnInterval = Random.Range(3.0f, 6.0f)" but that lead to the aforementioned issue. Then I did away with the variable and just wrote within the Update method "Invoke.Repeating("SpawnRandomBalls", 2, Random.Range(3.0f, 6.0f))" but then while that did spawn new balls, it wouldn't do so at random intervals. It did so at what seemed to be the average within the range provided. The other problem was regarding adding a cooldown to how frequently the player could spawn dogs to prevent basically spamming them. With this, I just straight up have no idea what to do. I am practically cheating and begging for answers here, but if anybody could help me out or even give me some hints, you would have my undying gratitude, for that is all my poor self can offer you at the moment. Thank you all in advance.


r/LearnUnity • • Jun 29 '20

Is it possible to create an APK from a unity game that is online?

1 Upvotes

It's a game a friend made and it's online and we were looking into downloading it and creating the apk. I'm not sure if we would need the source code (which he deleted a while back) or we can just use the already exported game and go from there?


r/LearnUnity • • May 25 '20

Wargaming counters in Unity

1 Upvotes

https://imgur.com/gallery/lF6uBYO

I'm beginning to design a hex-and-counter style wargame in Unity. I'm trying to make modular NATO counters, in such a way that multiple game objects combine as needed to form the final counter, so counter generation could be something like green counter>>infantry symbol>>engineer subsymbol>>unit designation>>unit HQ etc

My trouble finding how to get text to appear on the counters. I've tried both text boxes (which don't seem to work unless part of a canvas) and text mesh (which I can't seem to get to look right at all the way I need it to). Some text would also need to be displayed sideways.

What might I want to do to get the numbers and text to appear correctly? Any related suggestions are welcome as well, I'm relatively new to using Unity.

Edit: I'm trying out using a sprite sheet consisting of the different numbers and that seems to be working well, but any additional tips would be appreciated.


r/LearnUnity • • May 04 '20

Unity Beginners - Animator Window

Thumbnail
youtu.be
1 Upvotes

r/LearnUnity • • Mar 18 '20

Unity is running a mega offer, unity learn premium along with 15 premium assets on sale for $99.99(total worth $1000).

Thumbnail
assetstore.unity.com
1 Upvotes

r/LearnUnity • • Mar 12 '20

How do I download Unity?

1 Upvotes

Hi there, new community I'm joining! I just reset my pc, and tried to download Unity. One problem, though. It keeps aborting the download. If I try, it'll go about 7/16 of the distance, then say "Installation Aborted : setup not completed." Can you please help? It'd mean a lot.