1
\$\begingroup\$

I am making an isometric game (3d scene, using 2d sprites). Currently I am trying to add collision to the enviroment to prevent the player from walking through everything. However no matter what I do the player seems to simply ignore the and walks through the object. Below are some combination I have tried and the results I got. For this instance I am looking at the windmill object

NOTE: Player has a character controller , no rigidbody.

Scenario 1:

  • Windmill has Rigibody
  • IsKinematic false
  • No rotation & Position constraints
  • Boxcollider isTrigger == false

result: On touching object it start flying around. So collision is there.

Scenario 2:

  • Windmill has Rigibody
  • IsKinematic false
  • has rotation & Position constraints (all axis)
  • Boxcollider isTrigger == false

result: I can walk through the object and somehow the collision is gone. the reason for constraints is so that the object wont move. (its a windmill)

Scenario 3:

  • Windmill has Rigibody
    • IsKinematic false
    • both with and without rotation & Position constraints (all axis)
    • Boxcollider isTrigger == true

result: Debug.Log shows that there is collision

Now what I would like to achieve is that the windmill can't be moved yet also can't be moved through.I am willing to programm collision if needed, but i rather do it with the unity provided tools. Any idea what I am overlooking?

EDIT 1:

Since it was asked how I moved the player, I use the Fingers asset. We make use of the joystick to move the player around. Below is our JoystickExecuted method depicting what exactly I do.

 private void JoystickExecuted(FingersJoystickScript script, Vector2 amount)
{
    if (amount.x > 0 && !_facingRight)
    {
        FlipXAxis();
    }
    else if (amount.x < 0 && _facingRight)
    {
        if (amount.x > 0 && !_facingRight)
        {
            FlipXAxis();
        }
        else if (amount.x < 0 && _facingRight)
        {
            FlipXAxis();
        }
    }
    var pos = transform.position;
    pos.x += amount.x * 8 * Time.deltaTime;
    pos.z += amount.y * 8 * Time.deltaTime;
    transform.position = pos;
    _anim.SetBool("isWalking", true);

    if (amount == Vector2.zero)
    {
        _anim.SetBool("isWalking", false);
    }
}
\$\endgroup\$
  • 1
    \$\begingroup\$ Why has the player no Rigidbody? \$\endgroup\$ – Eldy Jan 10 '18 at 16:40
  • \$\begingroup\$ This has been tested but also did't work. It will later however. As rigibody affects game performance a lot \$\endgroup\$ – KevinTheGreat Jan 10 '18 at 17:02
  • \$\begingroup\$ How are you moving the PlayerController? \$\endgroup\$ – Ed Marty Jan 14 '18 at 16:38
  • \$\begingroup\$ @EdMarty it is a mobile game, we are using fingers for that. assetstore.unity3d.com/en/#!/content/41076 I added the method responsible for the joystickmovement \$\endgroup\$ – KevinTheGreat Jan 15 '18 at 11:28
  • 2
    \$\begingroup\$ You should not set transform.position. Instead use CharacterController.Move and this should correct strange jittering issues. Also, use OnControllerColliderHit to listen for collisions. \$\endgroup\$ – Ed Marty Jan 16 '18 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.