Permalänk

Unity, funktioner och anrop.

void OnCollisionEnter2D(Collision2D other) { if (transform.position.y > other.transform.position.y) { animate.SetBool("isOnGround", true); } if (other.collider.tag == "Enemy") { ContactPoint2D point = other.contacts[0]; Debug.DrawLine(point.point, point.point + point.normal, Color.red, 10); Debug.Log(point.normal); if (point.normal.y >= 0.99f) // kollar om normalen är större { rb.velocity = new Vector2(rb.velocity.x, GetComponent<PlayerMovement>().JumpHeight); if(otherScript != null) { otherScript.die(); } }

public class EnemyMovement : MonoBehaviour { public void die() { Destroy(gameObject); Points.AddPoints(pointsToAddEnemy); GameObject objSmoke = Instantiate(Smoke, transform.position, transform.rotation) as GameObject; Destroy(objSmoke.gameObject, 6); } }

Har ett problem men ett spel jag håller på att göra som inte gör det jag vill den skall , jag har två klasser, där jag vill anropa en funktion i ena klassen efter en kollision.
Koden ovan är så som det ser ut nu och den gör ingenting.

Visa signatur

dator: Intel Core i5 3570K | Noctua NH-D14 | MSI Z77A-GD65 ATX | Corsair 16GB 1600MHz VENGEANCE LP | XFX Core Edition 850W 80+ Bronze | Corsair Carbide 500R | Sapphire Radeon HD 7970 GHz 3GB | Samsung SSD 840 Series 250GB | 2st. 2TB Seagate Barracuda 7200rpm SATA 6Gbit/s | DVD±RW Samsung 24X DL
Kringutrustning: ASUS MX279H 27" | Microsoft sidewinder x4 | Func MS-3 v2