Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Answer my questions

Discussion in 'Getting Started' started by reptiliantroll, Mar 21, 2017.

  1. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    Ok so look at my code:
    Vector3 input = new Vector3 (Input.GetAxisRaw ("Horizontal"), 0, Input.GetAxisRaw ("Vertical"));
    Vector3 direction = input.normalized
    What does .normalized mean, what does it do, it it necessary for movement on objects?
    What is transform.Translate, what does it do and how does it work?
    If I want to make my game multiplayer, do I need to pay in anyway?
    I will ask more questions soon.
     
    Last edited: Mar 21, 2017
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Gummi_Ghost likes this.
  3. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    I forgot to say that I want people themselves to explain it to me in deep detail, it's hard to understand the guides because they're just so complicated, and instead I want people to explain it to me in a simple way.
     
  4. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,498
    Okay, first of all... the response you were looking for towards @DanielQuick was "Thank you." A little courtesy goes a long way.

    Second, do not simply bump threads. Especially not ones that you last posted in 2.5 hours previously. You appear to do this a lot. The people who answer questions on these forums are normal people who work their regular jobs and spend time with their families. And you know, sleep and stuff. We'll get to your question when we can, regardless of whether it's at the top of the page or not. In fact, seeing someone demand attention with a "bump" makes us feel less inclined to care.

    Third, if you find your question is going unanswered, instead of bumping consider that you might need to provide more detail so people can provide a meaningful answer. Or, people might not be responding because your question could be answered with a simple Google search.

    Fourth, the API documentation does have some iffy areas, but the entry on Vector3.normalized is pretty straightforward. Did you actually read the link that was shared? If you don't understand what any of that means, it sounds like you're in too deep and need to go back and learn the basics again.

    Lastly, if you're not sure what .normalized is, why are you using it? Is it from a tutorial you're doing or something? And if so, does the tutorial not explain why you're using it? You should never just be pasting code into your project without knowing what it does.
     
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    18,246
    Welcome to programming. This is one reason why not everyone on these forums is a programmer. You need a certain mindset, you need an understanding of mathematics, etc and some people simply cannot reach that point in a reasonable span of time. So they become artists, they become level designers, and so on.

    It's a mathematical term. If you absolutely must have the math behind it you can check the link below, but it basically sets the length of the vector to 1. It's primarily used to determine the direction of a vector like in the example code you gave.

    http://stackoverflow.com/questions/11644356/what-does-it-mean-to-normalize-a-value/11644561#11644561

    Is it necessary for movement? Yes, if you want to know the direction the player is moving the controller.

    This one is explained by the link provided earlier.
     
    Last edited: Mar 21, 2017
  6. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,498
    Before the artists come at us with pitchforks and torches, some people are already very talented designers/artists and don't have an interest in programming. I think the most successful people in any position recognize their strengths and weaknesses, focus on their strengths, while working with people who compensate for their own weaknesses.

    Writing good code is hard. Making good art is hard. Creating good music and sound is hard. Designing good gameplay is hard. If it were easy, literally everyone would be doing it (instead of the current figurative everyone that's doing it...)
     
  7. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    1.Yeah, but he didn't help me because I allready read that and i'm impatient right now to get answers, i hate when I have to wait for hours just to get a simple question answered.
    2.Like I have said, impatience, and impatience = get things done quicker = learn better = make my game.
    3.Maybe I will do that.
    I don't see why people wouldn't answer, this is a questions thread.
    4.Look, let me explain my problem in a simple way: the Unity API explains complicated things... with complicated things.
    I have to look 100 other things up in order to understand this one thing! when a person here can just explain it simply in a few minutes.
     
  8. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    Ok, even if a vector has a lot of complicated math going into it, doesn't mean you cannot explain it to me in a simple way,
    yes I need an understanding of mathematics to learn this, but not as much as you think.
    "It's a mathematical term. If you absolutely must have the math behind it you can check the link below, but it basically sets the length of the vector to 1. It's primarily used to determine the direction of a vector like in the example code you gave."
    Ok you're missing a point here, I allready read the Unity API, but what I want to know is WHY setting a vector's length to 1 causes movement in Unity.
     
  9. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    And guys, all I need is a simple and understandable explanation to my questions. For a beginner in Algebra to understand a complicated equation, he just needs to understand the basic 2 sides, same with my questions, if you show me the basics of it in a simple way, I will then be able to understand the more complicated parts.
     
  10. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    It doesn't, it gives you a normalized direction which you may or may not want to use as a direction to move in.

    Transform.Translate performs the movement, as explained in the Scripting Reference linked above.


    Let's say you want to move towards a target at a specific speed.

    The vector you want to travel is TargetPosition - ThisPosition.
    If you Translated that amount, you would arrive at the destination immediately. No good.
    If you normalized that amount, you have the direction you want to move in.
    Now you are free to multiply the direction by the speed you want to travel to find how far you want to move over 1 second.
    Multiply that value by the deltaTime to find how far you should travel in a frame.
    Translate by that last value.
     
    Schneider21 likes this.
  11. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    Wow, that was extremely helpful, you definitely deserve a thank you :)
    That was a simple and understandable explanation for a beginner programmer to understand. See, instead of reading all that which would take about an hour or more for me to understand, it only took your reply a minute to make me understand, now I think you guys see my point.
     
  12. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,240
    One day you will be on the other side, and you will feel regret.

    Respect your peers, no matter their advice.
     
  13. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    This forum has a like button next to each comment ;)

    In general we are more than happy to help others getting started, though you have a much better chance of that with a good attitude and etiquette. Your thread title for example ("Answer my questions") is phrased as an order and nobody likes being ordered around. Most of your writing follows a similar theme.
     
  14. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    Remember, I said I'm impatient to learn all this, once I learn the simple stuff, i can learn the complicated stuff, not the other way around which is of course hard.Of course when I know all the basics, I will want to be on the other side.
     
    Last edited: Mar 21, 2017
  15. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    Yes, I apologize for being like that, but my impatience is high when I want to learn something.

    Ok just to get it straight, normalizing a vector "takes the magnitude(length) out of it", leaving you with just a direction, right?
    for example:
    Vector: 10 units North
    Direction: North
    Magnitude: 10 units
    So if I do this:
    input = 10
    input.normalized <--- if I multiply this times deltaTime and "Translate" it, I will move 10 units in whatever amount of time the last frames were, correct or not?
     
  16. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    An input of 10... I'll assume 10 units 'north'
    No, you would move 1 unit/second north.
     
  17. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    18,246
    Because your attitude is chasing most of us off. We're not paid to answer your questions.
     
  18. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    Yes sorry I meant to say that, i put 10 instead.
     
  19. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    Explain why.
     
  20. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    Another question was added, please answer it thank you.
     
  21. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,240
  22. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    Don't post useless comments and just answer my questions.
     
  23. SarfaraazAlladin

    SarfaraazAlladin

    Joined:
    Dec 20, 2013
    Posts:
    279
    Wow. I wish you zero luck on your journey. And I wish everyone who attempted to help you the best of the best - you're all first class internet citizens.
     
    arkano22 likes this.
  24. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    And you think I care about your stupid wish? luck is just some phony made up thing, so it won't affect me lol.
    And Schneider21 liked the comment "Hahahaha," I do not know why, is he envious or something? I mean damn schneider... i was just stating my points, not insulting you.
     
    Last edited: Mar 22, 2017
  25. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    I created this topic for questions, not arguments, so just calm yourselves everybody, I get it... my attitude is agressive, but it's because I want to learn.
     
  26. reptiliantroll

    reptiliantroll

    Joined:
    Aug 20, 2016
    Posts:
    33
    LOL I pissed everyone off, maybe that's why my questions aren't being answered, I seriously apologize now.
     
    Last edited: Mar 23, 2017
  27. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    18,246
    Just wait till you start trying to sell your games. Luck is a very important part of the whole process. At least for those of us who do not have millions of dollars for marketing and a well known series (eg Call of Duty).

    We don't believe you. :p
     
    Gummi_Ghost and Dave-Carlile like this.
  28. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,796
    This at least shows a bit of awareness. (Beyond that already shown by your choice of username.) So, maybe there's hope for you yet.

    Some suggestions:
    • Start a new thread. And in that thread, don't be an asshole.
    • Ask for help, don't demand it. Nobody here is your slave.
    • If you get a reply, remember that somebody took time out of their workday or free time to try to help you. Show a little appreciation for that.
    • If you have follow-up questions, post them as replies. Don't edit previous posts except to correct typos or similar.
    • Once you've resolved the specific question you came with, let that thread die peacefully, and with your next question, start a new thread.
    • Also, don't be an asshole.
    If you can do this, and luck is on your side, those you have already offended will find it in their hearts to give you another chance. If not, then you're probably on your own, but study hard and maybe you can create something great anyway.
     
  29. Dave-Carlile

    Dave-Carlile

    Joined:
    Sep 16, 2012
    Posts:
    967
    This made me laugh. Seriously though, there are many days I wish I were an artist rather than a programmer.
     
    Ryiah likes this.
  30. RaidedKing

    RaidedKing

    Joined:
    Aug 29, 2021
    Posts:
    2
    i have error code cs1513 i have looked everywhere and cant find a solution please help
     
  31. RaidedKing

    RaidedKing

    Joined:
    Aug 29, 2021
    Posts:
    2
    this is my code

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

    public class PlayerController : MonoBehaviour
    {
    public Animator anim;
    public Rigidbody2D rb;
    public float jumpForce;
    public float playerSpeed;
    public Vector2 jumpheight;
    private bool isOnGround;
    public float positionRadius;
    public LayerMask ground;
    public Transform playerPos;

    void Start()
    {
    Collider2D[] colliders = transform.GetComponentsInChildren<Collider2D>();
    for (int i = 0; i <colliders.Length; i++);
    {
    for(int k = i + 1; k < colliders.Length; k++)
    {
    Physics2D.IgnoreCollision(colliders, colliders[k]);
    }
    }



    void Update()
    {
    if(Input.GetAxisRaw("Horizantal") != 0)
    {
    if(Input.GetAxisRaw("Horizantal") > 0)
    {
    anim.Play("Walk");
    rb.AddForce(Vector2.right * playerSpeed);



    }
    else
    {
    anim.Play("WalkBack");
    rb.AddForce(Vector2.left * playerSpeed);



    }
    }
    else
    {

    anim.Play("idle");
    }
    isOnGround = Physics2D.OverlapCircle(playerPos.positionRadius, ground);
    if(isOnGround == true && Input.GetKeyDown(KeyCode.Space))
    {
    rb.AddForce(Vector2.up * jumpForce);
    }
    }
    }
     
  32. UnityMaru

    UnityMaru

    Community Engagement Manager Unity Technologies

    Joined:
    Mar 16, 2016
    Posts:
    1,227
    Please refrain from bumping years old threads with questions with little to no context. We'll need more information such as what you are trying to accomplish, what version of the editor etc.
     
    Gummi_Ghost and JoeStrout like this.
  33. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    8,737
    Please
    - make your own thread, do not necro unrelated threads of others, it is free of charge, read the code of conduct
    - always use code tags: https://forum.unity.com/threads/using-code-tags-properly.134625/
    - always copy and paste THE ENTIRE error message
    - you probably want to sit through a couple of beginner C# tutorials before you start with complex code
    - check your {}s you probably missed some or have some extra, hard to tell in your wall of italic text
     
    VirtualDimension and JoeStrout like this.
  34. VirtualDimension

    VirtualDimension

    Joined:
    Dec 14, 2021
    Posts:
    2
    Normalizing means transforming it to whatever number it previously was to a maximum of 1 and minimum of 0 (which is done by dividing each axis by the magnitude), it's useful if you need a vector direction regardless of its magnitude: after all you just need to know where it is going, and you don't really care about the magnitude, otherwise strange things would occur when moving diagonally, I recommend watching some videos about it to clarify any doubts.
     
  35. meghnazala746

    meghnazala746

    Joined:
    Dec 28, 2020
    Posts:
    8
    INSTANCE ISSUE

    if i have 2 prefab instantiated in scene and in child of both the prefab i attached same script then when i destory any one of theme then for another prefab gameobject instance will become null.

    how to deal with it?

    thanks in advance...
     
  36. pteryx08

    pteryx08

    Joined:
    Jan 13, 2022
    Posts:
    1
    Pourquoi lorsque je drag mon script sur mon joueur on me dit « cant add script »
     
  37. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
unityunity