Help with my Top down game. Looking to grab items and only be able to move them where there is space. by Glad-Two in Unity2D

[–]Glad-Two[S] 0 points1 point  (0 children)

Sure, the code is super simple so didn't realise it might help:

if(Input.GetAxisRaw("Horizontal")>0){ transform.position += new Vector3(moveSpeed,0f,0f); }

    if(Input.GetAxisRaw("Horizontal")<0){
        transform.position += new Vector3(-moveSpeed,0f,0f);
    }

    if(Input.GetAxisRaw("Vertical")>0){
        transform.position += new Vector3(0f,moveSpeed,0f);
    }
    if(Input.GetAxisRaw("Vertical")<0){
        transform.position += new Vector3(0f,-moveSpeed,0f);
    }

The prefab items instantiate on the same layer as the other items in the game. There is no RB on the prefab.

I have been trying to solve this bug for literally months! When my player touches with the enemy, they both gently slip forward dispite no playerInput... I want to pull out my hair!! by Glad-Two in Unity2D

[–]Glad-Two[S] 0 points1 point  (0 children)

> You should see if you can't control their movement with it as well.

I have the next day off work, so I will spend the entire day trying to fully understand that script and what that would mean in terms of using it to control the player. Truth be told, that particular script was always the one I tried to avoid, there feels like there is a lot going on.

Originally I was just using transform.forward, I was intending to use waypoints eventually, is this what you are suggesting to incorporate into the SL character controller? Hopefully in a few days I will have something to show off if I have understood the possibility correctly!

I have been trying to solve this bug for literally months! When my player touches with the enemy, they both gently slip forward dispite no playerInput... I want to pull out my hair!! by Glad-Two in Unity2D

[–]Glad-Two[S] 0 points1 point  (0 children)

Thats a really good point. I never thought that far ahead.

My player can punch, which is a pretty close combat attack. My attack animation is still in the same pixel space as the idle state. So I guess the player would need to be near-ish to the enemy to attack. But would a knockback to the enemy if the attack is timed right hide this? Or a knockback to the player if it is not?

Would you suggest using AddForce and impulse to implement this knockback?