Unity 2D Platformer Tutorial 12 - Interaction System Setup

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

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

  • @Emilis2023
    @Emilis2023 Год назад +2

    Hey, I've only been playing with Unity for a couple of weeks now, and this was exactly what I was looking for. Thanks so much for the simple explanation! It's behaving exactly like I wanted in my project now.

  • @beri4138
    @beri4138 4 года назад +15

    "Lets draw a nice little star"
    *Draws Satanic pentagram
    lmao

  • @hat5583
    @hat5583 2 года назад +2

    these videos are really great. thanks for making them.

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

      😇😇😇🙏🏻🙏🏻🙏🏻

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

    thanks dude! Learnt alot

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

      I'm always glad to help

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

    Thank you!!!!! this helped me a lot

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

      Ayoooooo
      You're welcome 😎😎😎

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

    For those that may not be able to see the debug statement. In the console, make sure the messages part (the circle with the exclamation mark inside it) is enabled. Click on that to enable it. I think mine was disabled, then after enabling it I can see the debug statement.

  • @beri4138
    @beri4138 4 года назад +4

    I thought about this video for a while and I disagree with you. InteractionSystem should be an interface, not a base class. Items should be able to implement InteractionSystem and inherit from MonoBehaviour.
    Still a great video.

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

      Hey,
      It's true but I'm not a big fan of using interfaces for simple stuff but you are 100% right, for common structure interfaces are the way to go.
      Thanks for pointing out man 🙏🏻

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

    Hi my InteractCheck object is not flipping with my character sprite, Any idea why?

    • @wesleyfortin6251
      @wesleyfortin6251 3 года назад +2

      Nevermind... I was trying to be smart and use the SpriteRenderer FlipX and forgot that it wont apply to anything attached to the fox object. Great tutorial series so far, however I was also wondering why you chose to use the array of colliders for checking if on the ground instead of just isTouchingLayers(groundLayer) which would give you the same output if I'm not mistaken. New to unity so let me know!

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

      Thank you, and you are totally right.
      Using IsTouchingLayers is also a good choice, but you'll need to create the Collider2D before hand and pass it in the method, where the overlapcircleall gives you the ability to create it on runtime, as for the array, You can use subtle as well , that's just my personal preference to check more than one collision . 😇

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

    This video is 2 years old, does it still work?
    I'm kinda scared of tutorials that are more than 1 year old, a lot of them are obsolete :(
    And, how could I get it to show a "Press E to interact" text while in the area?
    Edit: I FIGURED IT OUT!!!

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

      Hey,
      I feel you in that matter, as far as I remember, what've used in the tutorial are common stuff and if anything does say obselete you can simply use the new method.
      And for the press E thing, you can trigger showing a text in the ui everytime the player triggers with the object you want to interact with

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

      @@Antarsoft Yep! I've been working on it since I wrote that comment
      I'm almost there

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

      Great to hear that, if you face any issues try working your way through them but when it reaches dead end reach out!

    • @candylide
      @candylide 2 года назад +2

      @@Antarsoft Thank you!
      Just yesterday I finally made it work, I have a funtional interactive system!! I even put invisible walls that dissapear after interacting
      I still can't believe I did it
      This is the charm of game development, isn't it?

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

      It is, yes
      You find out you are capable of doing more and more
      Good stuff amigo

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

    Mine didn't work FeelsBadMan, when I press "E" the console doesn't show any messages, why?
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class InteractionSystem : MonoBehaviour
    {
    public Transform detectionPoint;
    private const float detectionRadius = 0.2f;
    public LayerMask detectionLayer;
    void Update()
    {
    if(DetectObject())
    {
    if(InteractInput())
    {
    Debug.Log("Interact");
    }
    }
    }
    bool InteractInput()
    {
    return Input.GetKeyDown(KeyCode.E);
    }
    bool DetectObject()
    {
    return Physics2D.OverlapCircle(detectionPoint.position,detectionRadius,detectionLayer);
    }
    private void OnDrawGizmosSelected()
    {
    Gizmos.color = Color.green;
    Gizmos.DrawSphere(detectionPoint.position, detectionRadius);
    }
    }

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

      If you can check these things:
      -proper position of detection point
      -the intractable gameobject has a trigger collider
      -proper layer for the intractable object
      Do use debut statements everywhere if you want to make sure you are reading a specific point in the script

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

      @@Antarsoft Alright, thank you so much

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

      @@Antarsoft Do I need to have the detection points when my player already collides with things otherwise? Didn't follow the series through just watched this video alone

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

      Depends on what you wanna achieve.
      Those detection points are used for trigger , not physical collision.
      I'm using them to detect the ground, wall, overhead ceiling, and interactable objects.

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

      In the console, make sure the messages part (the circle with the exclamation mark inside it) is enabled. Click on that to enable it. I think mine was disabled, then after enabling it I can see the debug statement.

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

    Please do an enemy ai🙏

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

      Will do it after the inventory system 😎

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

      Inventory would be great 👍🔥

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

      Exactly, this section "interaction system" has couple videos then the next section will commence "Inventory system"

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

    i was wondering, why didn't you just use
    void OnTriggerEnter(collider collision)
    {
    }
    i mean wouldn't it have made it easier and less steps.
    or is it cuz you can not use that function?

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

      Technically you will get the same output but I opted to use that method cause I want the interaction to be in a specific area, otherwise using the OnTriggerEnter on the existing object will use its collider (whole area)

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

      @@Antarsoft oh i see i guess that makes sense. well ama try the ontrigger and see how i can make it work