#No collision between objects

1 messages · Page 1 of 1 (latest)

mossy skiff
#

I don't know why, but my player don't have collision with "boundries"

#

Player:

#

Boundry

#

The Movment is by the "New" input system by this script

#
using UnityEngine;
using UnityEngine.InputSystem;

public class Movement : MonoBehaviour
{
    Rigidbody2D playerrb;
    float movementSpeed = 5f;
    void Start()
    {
        playerrb = GetComponent<Rigidbody2D>();
    }

    public void Move(InputAction.CallbackContext context){
        playerrb.velocity = new Vector2(context.ReadValue<Vector2>().x * movementSpeed, 0);
    }
    
}
desert sonnet
#

can you show me your polygon collider in game?

mossy skiff
#

Yes moment

#

Boundries

#

Player

desert sonnet
#

ah alright

mossy skiff
#

Both are on same Layer (default)

#

Player is only moving by X axis

desert sonnet
#

oh the screen?

mossy skiff
desert sonnet
#

gotcha

mossy skiff
#

So player can't go off it

desert sonnet
#

try setting your player to Dynamic and turning off gravity for a second

mossy skiff
#

Active? Dynamic u mean?

desert sonnet
#

oops

#

yea

mossy skiff
#

Yea on Dynamic it's working

desert sonnet
#

nice

mossy skiff
#

But then, why the option for Collision between Static/Kinematic exist?

desert sonnet
#

must be some better way to implement it

mossy skiff
#

The is this special field

#

to enable Kinematic/statick collision

#

and it's checked for me

#

but don;t change anything :/

desert sonnet
#

you could try using MovePosition instead, but I'm not 100% sure if it will help

mossy skiff
#

For now I think I will just put it in dynamic with 0 gravity on the player and locked Y axis so it can;t move

#

Thanks for help anyway 🙂