Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Sovo

Pages: [1]
1
Support / Re: Collision for Sprites/Tilemaps
« on: January 08, 2014, 07:52:08 pm »
That seems to be the issue and why none of my collisions were working.  Thanks again for your help.

2
Support / Re: Collision for Sprites/Tilemaps
« on: January 08, 2014, 04:32:37 am »
After some more testing, I can get the player sprite to trigger a collision with the other sprite by setting it to a box collider in the sprite collection editor.  However, polygon collider still does not fire a collision event.  Nor does the tilemap mesh collider.  I have a feeling this has something to do with mesh colliders, but I'm the only one who seems to be having a problem.  I must have missed something very basic.

3
Support / Re: Collision for Sprites/Tilemaps
« on: January 08, 2014, 03:25:38 am »
Okay.  I have made the changes you recommended. 

Code: [Select]
public class PlayerScript : MonoBehaviour {

// Use this for initialization
void Start () {
        Debug.Log("started");
}

// Update is called once per frame
void FixedUpdate () {
        rigidbody.MovePosition(rigidbody.position + new Vector3(-10f * Time.deltaTime, 0, 0));
}

    void OnCollisionEnter(Collision collision)
    {
        Debug.Log("collision entered");
        GameObject.Destroy(this);
    }
    void OnTriggerEnter (Collider other) {
        Debug.Log("trigger entered");
        GameObject.Destroy(this);
    }
}

Movement is happening with ostensibly the same effect as transform.Translate.  However, the collision events are still not firing.  I'm going to try starting a project from scratch and document every step I take.  In the meantime, here's a screen of the editor, in case anything jumps out at someone.


4
Support / Re: Collision for Sprites/Tilemaps
« on: January 07, 2014, 05:12:21 pm »
Thank you for the reply.  The sprite's rigidbody is set to kinematic.  I'll try using the MovePosition method instead of the transform.translate method.  I've been following a few tutorials, and they're all using transform.translate, but they haven't been working with colliders, yet.

5
Support / Collision for Sprites/Tilemaps
« on: January 07, 2014, 06:22:00 am »
I have spent a few hours trying to get OnCollisionEnter or OnTriggerEnter to fire on a sprite's script without success.  The project composition is extremely basic.  Just a tilemap and two sprites.  The tilemap has a collider via the sprite collection settings, but no rigidbody.  The two sprites have colliders, also via the sprite collection settings, and both have rigidbodies.  I have increased the collider depth to 10 on all colliders and set their z-axes to 0.

My script looks like this:
Code: [Select]
public class PlayerScript : MonoBehaviour {

// Use this for initialization
void Start () {
        Debug.Log("started");
}

// Update is called once per frame
void Update () {
        transform.Translate(-10f * Time.deltaTime, 0, 0);
}

    void OnCollisionEnter(Collision collision)
    {
        Debug.Log("collision entered");
        GameObject.Destroy(this);
    }
    void OnTriggerEnter (Collider other) {
        Debug.Log("trigger entered");
        GameObject.Destroy(this);
    }
}

Do any problems jump out at anyone?  I appreciate any help and advice you can offer in advance.

Pages: [1]