#Hey guys I ve got this issue where

1 messages · Page 1 of 1 (latest)

stark ivy
#

I believe this is how I can create a thread

outer sandal
#

Yes, the title is a bit dumb, but it's fine lol

#

No worries, I fked the name of threads several times myself as well XD

stark ivy
#

so both these objects have two continuous circle collider

outer sandal
#

Those assets are cute

outer sandal
#

Did you make them yourself?

stark ivy
outer sandal
#

Oh damn

#

Nice

#

Anyway continue kek

stark ivy
#

yep yep haha

#

what happens is, when player clicks left mouse button, it Adds a force to the knife

#

towards the target ofcoz

#
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (!_startFreeze)
        {
            //Add knife moving towards Knife Landing Point

            if (collision.transform.tag == "Animal")
            {
                Debug.Log("HIT ANIMAL");
                //Give 0.2s then bounce back
                _rb.velocity = Vector3.zero;
                _rb.angularVelocity = 0f;
                _rb.AddForce((_knifePoint.transform.position - transform.position) * 5f, ForceMode2D.Impulse);
                StartCoroutine(EnterIdle(_attackIntoIdle));
            }
            /*
            if (collision.transform.tag == "Ground" && _currentState != States.Follow || collision.transform.tag == "Wall" && _currentState != States.Follow)
            {
                StartCoroutine(EnterIdle(_borderIntoIdle));
            }
            */
            _startFreeze = true;
        }
    }
hazy tendon
#

sorry to interrupt, don't know if this is a feature on 2d colliders but try setting collision detection to continuous

stark ivy
stark ivy
outer sandal
hazy tendon
#

well then other than increasing how often fixed update happens idk if there is a way

outer sandal
#

```cs
code here
```

hazy tendon
outer sandal
#

It doesn't work on phone

hazy tendon
#

I am always on pc

stark ivy
#
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (!_startFreeze)
        {
            //Add knife moving towards Knife Landing Point

            if (collision.transform.tag == "Animal")
            {
                Debug.Log("HIT ANIMAL");
                //Give 0.2s then bounce back
                _rb.velocity = Vector3.zero;
                _rb.angularVelocity = 0f;
                _rb.AddForce((_knifePoint.transform.position - transform.position) * 5f, ForceMode2D.Impulse);
                StartCoroutine(EnterIdle(_attackIntoIdle));
            }
            /*
            if (collision.transform.tag == "Ground" && _currentState != States.Follow || collision.transform.tag == "Wall" && _currentState != States.Follow)
            {
                StartCoroutine(EnterIdle(_borderIntoIdle));
            }
            */
            _startFreeze = true;
        }
    }
outer sandal
#

Or well, it's not visible on the phone

#

You didn't need to repost it, but sure

stark ivy
#

oh wow this is good haha didn't know about that cs thing my bad my bad

outer sandal
#

It's in the readme :P

stark ivy
#

hehe

outer sandal
#

There's a reason The Welsh Cow said that kek

stark ivy
#

so basically whenever it hits an animal, it should Debug.Log("HIT ANIMAL").

outer sandal
#

Why are you taking the tag from the transform?

#

shouldn't you take the tag from the gameObject?

#

And also you should use CompareTag()

stark ivy
outer sandal
#

I don't know but I've never seen it before with transform

#

I'd just use gameObject because it makes more sense

#

The tag is from the gameObject after all, not the transform

#

Even if it does work, I just wouldn't do it

#

It's odd

#

Regardless, you've to use CompareTag

stark ivy
#

hmmm ok I've changed it, but the issue seems to still be there

#

it does all the collision stuff, as in they collide and knife bounce off the pig, but it seems to not detect the collision

#

it's noticeable that it properly detects when the pig is stationary, but when the pig is moving and knife hits, it doesn't detect

outer sandal
#

What if you just put a knife without velocity in it's collider

#

If that doesn't work - then you know it's not the velocity

stark ivy
outer sandal
#

Ah okay

#

Does it get past this bool? @stark ivy

#

That's also pretty important

stark ivy
#

yes it does

outer sandal
#

hm

stark ivy
#
        if (!_startFreeze)
        {
            //Add knife moving towards Knife Landing Point
            Debug.Log(collision.gameObject.name);
            if (collision.gameObject.CompareTag("Animal"))
outer sandal
#

Can you show your updated code?

stark ivy
#

sorry one sec I may have found the issue

outer sandal
#

Ah

#

Take your time

stark ivy
#

fuhhh Im dumb haha

stark ivy
#

thus messing up the collision

stark ivy
outer sandal
#

Bro XD

#

You should use breakpoints :P

#

Or more Debug.Logs

stark ivy
#

not sure how to use in unity haha

outer sandal
#

Are you using VS?

#

Or VSC

stark ivy
#

VS

#

dw dw I will search it up haha

#

thanks for the advice!!

outer sandal
#

You can press the edge to set a breakpoint on a line

#

Then attach it to unity

#

And you're good to go

#

It's that simple :P

#

You also have a couple of buttons once the breakpoint gets hit

#

Such as step in, step out, continue etc.

#

You can look it up for more info

stark ivy
#

ok ok thanks thanks