What is a Transform (Unity Tutorial for Beginners - Position, Rotation, Scale, Vector3)

Поделиться
HTML-код
  • Опубликовано: 19 ноя 2024

Комментарии • 132

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  4 года назад +13

    🌐 Have you found the videos Helpful and Valuable?
    ❤️ Support on Patreon www.patreon.com/unitycodemonkey or get the Game Bundle unitycodemonkey.com/gamebundle.php

  • @kahville1
    @kahville1 6 лет назад +12

    This was a well made explanation what transform component does. Having developed a few school projects in unity i was not aware of the local component part. Good reminder on that for me. Thank you for your hard work.

  • @koushikkonda1994
    @koushikkonda1994 5 лет назад +28

    Thank you for advertising ...I found out an awesome channel

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +3

      Glad you like what you see!

    • @androidemulation5952
      @androidemulation5952 4 года назад

      Yes, i couldn't agree more. I started using unity recently and suddenly saw the Ad's and thank god i did.
      Great work Code monkey will be anticipating your next videos.

    • @twistedlink0875
      @twistedlink0875 3 года назад

      Yes

  • @SirSnowman
    @SirSnowman 5 лет назад +5

    thanks a lot again. I code on a daily basis, but unity and its own classes and references get me every time i try it. Thanks for making things clear!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +2

      Glad the video helped!

    • @francek3892
      @francek3892 2 года назад

      @@CodeMonkeyUnity I have imported some assets and took some prefabs from there and I saw that the positions of the prefabs aren't (0, 0, 0) I tried to reset the positions of the prefabs but I can't it doesn't allow me to do that, is there a way to change it bcs the position of the Z axis is -1.96 but it needs to be 0 so that it is on my terrain and not below the terrain?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      @@francek3892 Why can't you reset the position on the prefabs? You should be able to edit the position to anything you want
      Are you talking about creating them through code with Instantiate() ? The second parameter is the position

  • @rubenizquierdo9190
    @rubenizquierdo9190 6 лет назад +5

    omfgugfqflic, i spent almost an hour trying to understand the scale of unity. THX

  • @Aaron-vn5fd
    @Aaron-vn5fd 2 года назад +1

    I thought I was gonna know all this already and I still learned something!

  • @SmellGrow
    @SmellGrow Год назад +1

    thanks A lot your a real helper ❤❤❤

  • @oscarloria
    @oscarloria 6 лет назад +15

    Awesome, thanks! Please more 2D tips and tricks!

  • @AbuBakar-th5oo
    @AbuBakar-th5oo 5 лет назад +2

    Very easy to understand for beginners.

  • @abrahamliz2559
    @abrahamliz2559 4 года назад +2

    Your channel is exactly what I needed! Thank you for this

  • @AliveNotDeadmund
    @AliveNotDeadmund 4 года назад +2

    Love your work, mate! Thanks for opening the doors to Unity for many of us :)

  • @abdelhamide2011
    @abdelhamide2011 2 месяца назад

    I cant believe I skipped these valuable lessons and jumped to high level codes

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 месяца назад +1

      heh yup make sure you fully understand the basics!

  • @asmod9537
    @asmod9537 3 года назад

    Crystal clear.

  • @redresultyt
    @redresultyt 10 месяцев назад +1

    Love you

  • @Harvinderkaur2040
    @Harvinderkaur2040 3 года назад +1

    Thanks for the video

  • @abdallaayman3156
    @abdallaayman3156 4 года назад +1

    you r the best
    u really helped me

  • @masoudqashqai1449
    @masoudqashqai1449 4 года назад +3

    Code Monkey! , AWESOME JOB! Bravo!!, and may i say , Who Don't Wanna Learn By a Nerd Monkey??

  • @tuanngoc3704
    @tuanngoc3704 6 лет назад +4

    Please make more videos to guide beginner like me

  • @iamneoficial
    @iamneoficial 8 месяцев назад

    Thank you 😊

  • @soulhunter3523
    @soulhunter3523 5 лет назад +1

    Thank you ! You really helped me !

  • @yomaru_1999
    @yomaru_1999 4 года назад

    is this the best explain of sprite render on RUclips ?

  • @piraente6514
    @piraente6514 4 года назад +2

    The Unity Api says "you should only apply absolute values, not increment them" for the transform.eulerAngles.
    Do I misunderstand the description, or is the shown example not recommended?

  • @mrmelon2778
    @mrmelon2778 3 года назад

    Thank you this helped a lot!!

  • @neozoid7009
    @neozoid7009 2 года назад

    as always awesome

  • @winterguyVV
    @winterguyVV 5 лет назад +4

    Hi I really like these types of videos where you explain how things work rather than "heres a code, copy it into your project", that I found in most of tutorials. I have to ask the "ChildTransform" is preset input? Also how would you handle situation where you got 2 or more children for that object. Lets say you got Player with weapon as 1st child and camera as 2nd.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      What do you mean by preset input? The "ChildTransform" is just the name that I set on the child transform, it can be any name.
      You can have as many children as you want. You could have a Player game object and inside two children, a PlayerSprite and a Camera.

    • @JasonEllingsworth
      @JasonEllingsworth 2 года назад

      @@CodeMonkeyUnity see this is the problem. You put the code on the screen, but are not explaining it. If you make a beginner video, you need to explain it as if we know nothing.

  • @sa1ve_studioyarmukhametov667
    @sa1ve_studioyarmukhametov667 4 года назад +1

    Awesome videos!!!
    Thank you:)

  • @fieryninja2374
    @fieryninja2374 2 года назад

    very useful

  • @generalzeeten
    @generalzeeten 2 года назад

    nice job bro

  • @abdallaayman3156
    @abdallaayman3156 4 года назад

    thank you so much

  • @taldanieli213
    @taldanieli213 Месяц назад

    hi, im using vs 2022 and unity 2022.
    for some reason my code In c# doesn't recognize transform as an option
    what do i do

  • @algs5483
    @algs5483 5 лет назад

    Hello, I am brasilian and have you ever think to make a Portuguese channel for people that don’t understand English

  • @voluntaryneet9813
    @voluntaryneet9813 4 года назад

    5:22 You can also just do
    transform.position += new Vector3(.01f, 0, 0);

  • @ProductGuy4you
    @ProductGuy4you Год назад

    awesome, Thank you .........

  • @lfrohling
    @lfrohling 3 года назад

    Nice!

  • @kiPROBRos
    @kiPROBRos 3 года назад

    Excelent, thank you.

  • @adityarohanik0
    @adityarohanik0 6 лет назад +3

    So is " + new Vector3 " an alternative to creating a vector 3 variable and adding it to your Transform position?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  6 лет назад +5

      What line are you referring to? transform.position = transform.position + new Vector3(0.01f, 0, 0) ?
      Sure you can do it many ways
      Vector3 newPosition = transform.position + new Vector3(0.01f, 0, 0);
      transform.position = newPosition;
      Or you could do
      transform.position += new Vector3(0.01f, 0, 0);

    • @adityarohanik0
      @adityarohanik0 6 лет назад +1

      @@CodeMonkeyUnity Yes, I'm referring to that. Thank you

  • @benthompson754
    @benthompson754 2 года назад +1

    Hey, I know this is a bit old, but I had a question while I was watching the video.
    When you use the code to manipulate the rotation, the child object rotates around the parent object, treating the parent’s pivot like its own pivot.
    Is there a way to keep the parent-child relation, but prevent the child from rotating around the parent? That way they could still move in the line together, but just rotate in their own circles, rather than make one big one?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      I'm not sure I understand, if you want to rotate just the child along the child axis then you can modify the child.localEulerAngles or child.localPosition
      Alternatively mabye you can unparent the child, move it, then re-parent it

    • @JasonEllingsworth
      @JasonEllingsworth 2 года назад

      @@CodeMonkeyUnity he wants to rotate the parent without affecting the child.

    • @RomanMines64
      @RomanMines64 2 года назад

      I know this is 4 months late but something I could think of is storing the child's world rotation in a separate variable just before you transform the parent, and then immediately after apply the rotation back on to it? but this doesn't really sound like the best solution

  • @shantanavenkedeswar4615
    @shantanavenkedeswar4615 6 лет назад +1

    When I put transform.position = transform. position + new Vector3(0.01f, 0,0); , my spritedid not move at all but when I set it in transform.position = transform. position + new Vector3(0.07f, 0,0); it moves I don't get it why plus i did exactly at 8:11 but i got an error which is NullReferenceException:object reference not set to an instance of an object ,don't know how to fix it.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  6 лет назад +2

      Both those lines will move the transform, moving 0.07f units imply moves more than 0.01f
      If you're getting NullReferenceException on the line Debug.Log(childTransform.localPosition); then it means you have childTransform set to null.
      The variable is assigned in the previous line which does a transform.Find("ChildTransform"); so make sure the game object does have a child and the name is exactly "ChildTransform"

    • @shantanavenkedeswar4615
      @shantanavenkedeswar4615 6 лет назад +1

      @@CodeMonkeyUnity thank you! Your tutorial helps a lot

  • @ctluwua7695
    @ctluwua7695 3 года назад +1

    IS it important to use or learn c# to make games like this ??

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 года назад

      Unity uses C# so yes, but you can also make games entirely with Visual Scripting ruclips.net/video/qAkeCDWgPVA/видео.html

    • @ctluwua7695
      @ctluwua7695 3 года назад

      @@CodeMonkeyUnity How ?

  • @t3stbug
    @t3stbug 4 года назад

    do you have to have like notepad+ in order to write scripts? or is it a setting thing? i started with a tutorial so i dont know if i need to "take off" the training wheels?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад

      I use Visual Studio Community

    • @t3stbug
      @t3stbug 4 года назад

      Code Monkey I appreciate that. I am doing this on a custom computer, and after rigorous googling I found that visual studio would’ve come pre installed if I didnt mess around with my install! Definitely subscribing your videos are more than helpful!

  • @pitfulll6859
    @pitfulll6859 2 года назад

    Thanks for the tutorial! Do you know if there's a way to change the movement direction based on a changing direction? I have a arrow gun that rotates to face my player but I have no idea how to make the arrows that shoot out shoot in the direction of my player if that makes any sense 😅

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      You can calculate the direction vector and set transform.forward
      Or you can use transform.LookAt();

  • @changeahead8219
    @changeahead8219 2 года назад

    I have a question. There is a unit, the rotate character engine. I want to control this with keys, for example, when it is stationary, it returns when the key is pressed. GetKey commands don't work by the way.
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class Rotate : MonoBehaviour
    {
    public float RotationSpeed = 1f;
    private void Start()
    {

    }
    void Update()
    {
    if (Input.GetKey(KeyCode.I))
    transform.Rotate(new Vector3(0f, 1f, 0f).normalized * RotationSpeed * Time.deltaTime);
    if (Input.GetKey(KeyCode.K))
    transform.Rotate(new Vector3(0f, 0f, 0f).normalized * RotationSpeed * Time.deltaTime);
    }
    }

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      Everything there should work, is that script attached to a game object?

    • @changeahead8219
      @changeahead8219 2 года назад

      @@CodeMonkeyUnity Yes, that script attached to a game object,
      I want it to make a continuous rotation movement when I press "I" and then pull up.
      After that when I press "K" and then pull up, my gameobject must stop.

    • @changeahead8219
      @changeahead8219 2 года назад

      That is a propeller of engine.

  • @polihayse
    @polihayse 3 года назад

    eulerAngles is pronounced "oiler angles" just FYI. Thanks for the great tutorials.

  • @explosiver
    @explosiver 5 лет назад

    Unity keeps throwing compiler errors at me and Visual Studio won't pick up any of the function calls. Transform and debug just aren't registering to it and I'm not sure why. I made sure my code was identical to yours. I'm missing something I guess, but I have no idea what.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +1

      What compiler errors are you getting? Transform and Debug aren't being recognized in Visual Studio? Make sure you have the Visual Studio extension "Visual Studio Tools for Unity"

    • @explosiver
      @explosiver 5 лет назад

      @@CodeMonkeyUnity Ah, I never installed that. Thanks

  • @durianjaykin3576
    @durianjaykin3576 6 лет назад +2

    how to set the sprite renderer to a certain sprite, when initializing it?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  6 лет назад

      I don't think you can directly set the sprite in the constructor.
      The best way in terms of performance is:
      GameObject gameObject = new GameObject("mySprite", typeof(SpriteRenderer));
      gameObject.GetComponent().sprite = mySprite;

  • @kristianhristakiev9364
    @kristianhristakiev9364 3 года назад

    Thanks!
    I just want to ask how do you get these tips for the code from Visual Studio. Mine doesn't work with the Unity commands such as transform or Time.time etc.
    Any help?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 года назад

      On the Unity preferences set your IDE and install Visual Studio Tools for Unity

    • @kristianhristakiev9364
      @kristianhristakiev9364 3 года назад

      @@CodeMonkeyUnity Thank you!

    • @stasakarapandzic9286
      @stasakarapandzic9286 3 года назад

      @@CodeMonkeyUnity I still have the same problem, even though I have done all of this before I started coding... any other piece of advice please?

  • @boxitor9355
    @boxitor9355 4 года назад

    how do i make limits of scale

  • @RomanMines64
    @RomanMines64 2 года назад

    Hello I know this video is older and my question might not get answered, but I've noticed that since the transform function changes the position, scale, or rotation instantly. which could cause objects to just phase through it. but I want to transform an object the same way the inspector does it.
    here is my problem, its not the exact situation but ill simplify it.
    imagine a mesh collider wall that gets transformed to slide in a direction and what I want it to do is push on objects that it runs into and keep pushing them, just like how it would work if you just clicked on the X, Y, or Z values in the inspector and dragged them. but instead it just phases through all of the objects, even with a Lerp.
    but If I were to transform using the inspector, it does work exactly how I want it to.
    for the real situation that I am suffering through, I have a bunch of free floating "particles" or just spheres inside of a giant sphere, the big sphere has inverted normals so that the walls of the collider face the inside, not allowing anything to escape the inside of the sphere. I want to be able to scale the sphere up and down so that the particles inside of it would be forced to go to the center of the sphere, but I dont really want to add a force to the particles because every one of them already have a bunch of force calculations so they can attract and repel from each other

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      How thick is your wall? If it's super thin then it might cause issues but if it has enough thickness then it should work. As long as the distance for moving inside is shorter than moving outside the particle should move inside. Remember how the collider doesn't have to match the visual perfectly, you can make a thin wall visual with a thicker collider
      That's really it, changing it in the inspector or through code should have the same result, although when dealing with physics and scaling colliders things can become weird, the physics system does not like changing scales, if possible move the object instead of scaling.

    • @RomanMines64
      @RomanMines64 2 года назад

      @@CodeMonkeyUnity yeah, I'm going to make the particles take the radius of the circle and then use that to move the particles in and out of the center, thank you
      edit: also yeah I think the collider is infinitely thin

  • @soorenaasl9519
    @soorenaasl9519 2 года назад

    hello every body, i have a question in my mind for a long time and i will ask it here.
    what is difference between get the transform from a GameObject variable or Transform variable?
    i know you cant get a transform from GameObjects so why should i use Transform?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      What do you mean "you cant get a transform from GameObjects"?
      if you have a GameObject you can get the Transform with gameObject.transform
      And if you have a Transform you can get the GameObject with transform.gameObject
      All Game Objects must have a Transform and all Transforms must be attached to a Game Object

  • @Build_the_Future
    @Build_the_Future 4 года назад

    How do you move a transformer of your object only one time without it moving every frame and without using the void start?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад +1

      Store a float timer and count down on Update, do whatever you want when the timer elapses.

  • @giorgioguglielmone6528
    @giorgioguglielmone6528 4 года назад

    In the final part of your tutorial, you don't see any difference in value between "Debug.Log (childTransform.localPosition);" and "Debug.Log (childTransform.position);" why ?

  • @varshithpaturi2136
    @varshithpaturi2136 3 года назад

    CAN YOU MAKE THESE GAMES ON SCRATCH

  • @takedowngames4486
    @takedowngames4486 6 лет назад +2

    In need of help how do you make a unity android game immune to hacking

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  6 лет назад +6

      Preventing hacking is extremely difficult, if you're making a small game I would say don't bother.
      Giant companies like EA and Activision spend millions trying to stop it and there's always hackers.

  • @bsi-blakkseriesinitiative7717
    @bsi-blakkseriesinitiative7717 4 года назад

    Im struggling to make the child gameobject occupy the position of the parent object. I'm attempting to make one gameobject switch with another gameobject, but occupy the position of the previous gameobject. What do u do?
    This is in 3D btw.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад

      If you set the transform.localPosition to Vector3(0,0,0) it will be on the exact position of the parent

    • @bsi-blakkseriesinitiative7717
      @bsi-blakkseriesinitiative7717 4 года назад

      @@CodeMonkeyUnity thanks for the insight.
      So, if I write my code something like: gameobject2.transform. position = gameobject1.transform. localposirion = new vector3(0, 0, 0)?

    • @bsi-blakkseriesinitiative7717
      @bsi-blakkseriesinitiative7717 4 года назад

      @@CodeMonkeyUnity so the code i ended up with was:
      Void update
      If(whichAvatarIsOn >=0)
      Transform. Localposition = new vector3(0, 0, 0);
      The other gameobjects are loading, but not where the avatar was.

    • @bsi-blakkseriesinitiative7717
      @bsi-blakkseriesinitiative7717 4 года назад

      @@CodeMonkeyUnity fixed it. Thank you. I had an extra gameobject that was parent to what i thought was the parent.
      Thanks again.

  • @giorgioguglielmone6528
    @giorgioguglielmone6528 4 года назад

    In the tutorial do you use a figure (sprite) where can I find it?

    • @giorgioguglielmone6528
      @giorgioguglielmone6528 4 года назад

      Ah, found. It was about downloading another project that contained it.

  • @ctluwua7695
    @ctluwua7695 3 года назад

    Can we make games in unity without using c#

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 года назад

      Yes you can also make games entirely with Visual Scripting ruclips.net/video/qAkeCDWgPVA/видео.html

  • @yuvalgabay1023
    @yuvalgabay1023 5 лет назад

    Whats is locel value (like whats us the difference)

    • @tyrannosaurustits7083
      @tyrannosaurustits7083 5 лет назад

      Local space uses a specific point as the center, it's like when you sit in a moving car, you don't see you the car moving, but in reality you are moving with the car, that's local space

  • @070tahsin
    @070tahsin 3 года назад

    How can u make a reference to the child of the parent without using the name of the gameobj

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 года назад

      You can make a public field or a [SerializeField] private and drag the reference directly

  • @SaveNatureSaveYourself215
    @SaveNatureSaveYourself215 4 года назад

    Someone help me
    List targets
    How to find this targets with tag...

  • @johnnyguillen9363
    @johnnyguillen9363 5 лет назад

    How do i get an object to change from one form to another?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      What do you mean by form? You can scale it with localScale or if you're using a SpriteRenderer just give it another Sprite.

    • @johnnyguillen9363
      @johnnyguillen9363 5 лет назад

      @@CodeMonkeyUnity Its the latter, I meant changing it from one sprite to another.

  • @emad-dev
    @emad-dev 6 лет назад +2

    Hello. In to thank you to all the lessons to provided. But there is a problem is repeated lessons targeted for beginners, in fact brackeys channel and other channels discussed the basics of unity significantly there is no need to re-explained here. Just wish to be there lessons explain how to make a game. Or algorithms and other things like that.
    Thank you, abd sorry for my language.

  • @kfchotwings
    @kfchotwings 5 лет назад

    What is the point of using vector3 on a 2D game?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +1

      Unity's objects take in Vector3s (transform.position, transform.localScale)
      However a Vector2 gets automatically cast into a Vector3 when you try to assign it so you can work with Vector2's only if you want and Unity will handle the conversion.

  • @kantallive
    @kantallive 6 лет назад +1

    GLOBAL - there's B inside... you're pronauncing BLOGOL... ehhh what's the reason? where do u come from?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  6 лет назад

      I'm from Portugal so my accent might be a bit weird, I'm saying Global though, where are you hearing Blogol?

    • @kantallive
      @kantallive 6 лет назад

      @@CodeMonkeyUnity It sounds like this. I will use to it. Np :)

  • @DouseShinundakara
    @DouseShinundakara 5 лет назад +1

    Subtiles French ?
    Please ^^

  • @alphagamingayush9628
    @alphagamingayush9628 Год назад

    Bro help me It dont login when i try😪😪😪😪😪😪😪😪😪😪😪😪😪

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Год назад

      On my website? Use the contact form to let me know your email and I'll look into it

  • @leksetengah
    @leksetengah 2 года назад

    why vector3? not vector2?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      Unity is a 3D engine even if you're using it in 2D. You can use Vector2, Unity will automatically convert to Vector3

    • @SERBIANUGANDANKNUCKLES
      @SERBIANUGANDANKNUCKLES 2 года назад

      @@CodeMonkeyUnity please where to download extension that autocomplete those codes its really hard to type exectly the same as u without it i dont say it is impossible but its time consuming pls help

  • @Treetopper911
    @Treetopper911 3 года назад

    Pronounced 'Oiler' not 'You-ler'

  • @JasonEllingsworth
    @JasonEllingsworth 2 года назад

    Way too brief. It would be much more useful if you went in to detail of coding examples and explanations. Very hard to find something like this for transform. Everyone is doing this with multiplying the values/variables together and it doesn't make any sense to me why what is written in the code is changing what is happening on the screen.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      What exactly would you like more detail on? The transform component is pretty simple, just holds parent/child relations and 3 Vector3's

    • @JasonEllingsworth
      @JasonEllingsworth 2 года назад

      @@CodeMonkeyUnity more explanation of what people are doing in the code. Messing around with the unity UI is easy stuff, but I have been banging my head against the wall for 4 days trying to get things like shooting a bullet from an object that changes angles and the way that works in code makes no sense to me. Also things like making objects rotate to look at other objects automatically. Other examples I can't think about right now. It may be a simple thing but nobody is really explaining it like it that way.

  • @Sam2fn
    @Sam2fn 6 месяцев назад +1

    stop speaking like that

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  6 месяцев назад +1

      Like what?

    • @Sam2fn
      @Sam2fn 6 месяцев назад +1

      @@CodeMonkeyUnity OMG you replied! Bro You have 500k Subs. I am sorry you are the best