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.
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.
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.
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 🙏🏻
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!
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 . 😇
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!!!
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
@@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?
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
@@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
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.
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.
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?
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)
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.
Glad I could help!
"Lets draw a nice little star"
*Draws Satanic pentagram
lmao
😈
these videos are really great. thanks for making them.
😇😇😇🙏🏻🙏🏻🙏🏻
thanks dude! Learnt alot
I'm always glad to help
Thank you!!!!! this helped me a lot
Ayoooooo
You're welcome 😎😎😎
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.
Great hint, thakns
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.
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 🙏🏻
Hi my InteractCheck object is not flipping with my character sprite, Any idea why?
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!
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 . 😇
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!!!
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
@@Antarsoft Yep! I've been working on it since I wrote that comment
I'm almost there
Great to hear that, if you face any issues try working your way through them but when it reaches dead end reach out!
@@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?
It is, yes
You find out you are capable of doing more and more
Good stuff amigo
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);
}
}
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
@@Antarsoft Alright, thank you so much
@@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
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.
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.
Please do an enemy ai🙏
Will do it after the inventory system 😎
Inventory would be great 👍🔥
Exactly, this section "interaction system" has couple videos then the next section will commence "Inventory system"
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?
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)
@@Antarsoft oh i see i guess that makes sense. well ama try the ontrigger and see how i can make it work