#Collision
1 messages ยท Page 1 of 1 (latest)
Please post all relevant context in this thread
(Full inspectors of both objects, and relevant code)
NPC Inspector
Player Inspector
(It's identical, except there is no collision detection script on it.)
Script
Your most important script is not fully shown btw
So please make a screenshot of that
col.gameObject.CompareTag("tag")
Why do only some of your scripts have a tickbox and others do not?
Are they all applied to the original prefab?
Yes.
It hadn't been applied yet, you're right.
If you apply it, do the tickboxes reappear?
I applied it and changed to CompareTag.
No, they still don't appear on some scripts.
Oh, didn't know that! ๐
Still seems a bit odd to me, but sure heh
Regardless that'd pbb not be the culprit of the problem anyway, it just caught me off-guard
NPC has the collision detection script.
Player doesn't.
Player has "IsTrigger", NPC hasn't.
Both have rigidbodies 2D.
Both are kinematic.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollisionDetection : MonoBehaviour
{
public bool collided;
void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.CompareTag("Player"))
{
collided = true;
Debug.Log("yey!");
}
}
void OnTriggerExit2D(Collider2D col)
{
if (col.gameObject.CompareTag("Player"))
{
collided = false;
Debug.Log("yey!");
}
}
}
Hm, tried making both dynamic, still no luck.
I will read them. But I tried it in every possible configuration for the last 2 hours. Dynamic, kinematic, ...
That's 3D though so I'm currently looking at the 2D of it
IsTrigger on either one, OnCollisonEnter2D, on TriggerEnter2D...
Hmm there seems to be quite the difference with 2D and 3D regarding kinematic
I'd just use a dynamic rigidbody for now though
3D completely fucks your physics, and 2D doesn;t
For 2D it seems to be a hidden property, only accesed through code which is odd
I made this work easily before. Collision. I don't know what the freaking problem is this time. xD
But no matter what I try, it doesn't work.
place a debug.log outside of the if
See if that does anything
Wait how do the entities collide?
How are you moving object A to object B
1.) The debug outside doesn't show in console, when both objects meet.
2.) The collision happens by moving via WASD. It uses a script that gets RawAxis from Edit > Project Settings > Input Manager
Mind showing?
void gets called in Update I assume?
Yep.
Could you show the scene with both objects colliding with the bounding boxes visibly shown?
Or a video
btw after this is solved, look into enums and use those instead of strings
The thing that's moving is the "Mage" right
Yep.
It gets renamed by script, but is derived from prefab.
All attached scripts and configurations are identical.
Did you put the RB's on dynamic?
Both of them (NPC and Player) look like this now.
For a search with CompareTag - do both of the Game Objects need to be on the same layer maybe?
No.
What's your collision matrix?
I'd put them both on the default layer
Unless you tinkered with the matrix of the default layer
Was it that?
Welcome to programming XD
Bro...
Don't move them out of the default layer if you don't have to kek
Literally one fucking click on a checkbox cost 5 hours. xD
Should've pbb asked about it earlier, whoops
In code beginner a lot of people don't know what the collision matrix is so I don't ask it as the first thing kek
Welcome to programming lolol
I've been fixing a bug this entire workday, so y'know
Wumpie. I'm somewhat good with pixel art, UI design, quest design and lore stuff. If you ever need advice, an opinion, an idea - Please ask. ๐
I will never ever forget what the matrix is after today. Promise. xD
Well, leave and come back to it. That usually works for me. It randomly pops up in my head during the day, but I'm sure you know this. ^^
I really don't feel like leaving it over the weekend
Then I can read my code even less next monday XD
I'm working on a buff system but it's getting really complex
What are you working on? ๐
I guess the most practical advice is "never give up". It's generic, I know.
If I give up I'll fail my internship, so even if I wanted to, I don't have a choice XD
If you want I can send you the code over for fun
Sure, why not! ๐
I might answer slow, tho. I can't remember when I ate something for the last time and probably fix up smthg.
Buffs: https://gdl.space/itubafeqez.cs
UIBuffs: https://gdl.space/rinofakame.cs
Timer: https://gdl.space/durosafoce.cs
Have fun XD
No worries, it's not like you can fix my bug anyway
Only god and I know how the code works XD
I did fix the bug
But another bug took it's place
And now I'm even more confused kek
I probably actually found another bug I never knew was there
So that's an oof
Y'know what
You're probably right
I'll just go work in the weekend on it Ig
This bug is a lot bigger than I initially though
I suppose it's mainly due to poor code architecture choices, oof
Anyway ima go now then, I've a train to catch