RexObject is the base class for a RexActor. It allows for access to basic functionality which may be useful for some objects; full actors should utilize RexActor instead.

Public Methods

public void SetPosition(Vector2 position)

Sets the position of the object, including updating the attached RexController and RexPhysics if applicable. This is the preferred way of programmatically changing the position of an object in RexEngine, since RexPhysics will otherwise override the position.

public void PlaySoundIfOnCamera(AudioClip clip, float pitch = 1.0f, AudioSource source = null)

Plays the AudioClip passed in under the “clip” argument, but only if the RexObject is viewable on the main camera. If no AudioSource is passed in under “source”, it will attempt to use the AudioSource slotted under Slots > Audio in the Inspector.

public virtual void OnSceneBoundaryCollisionInsideBuffer()

This is called when an object is leaving the scene, and has touched a SceneBoundary but hasn’t gone deep enough into it to despawn. It’s designed to be overridden with unique effects for specific RexObjects if you need them.

public virtual void OnGravityScaleChanged(float _gravityScale)

An attached RexPhysics will automatically call this when its gravityScale changes. By default, this method will simply flip the Y scale of the RexObject, but it can be overridden to have unique effects.

public virtual void OnPhysicsCollision(Collider2D col, Side side, CollisionType type)

This notifies the RexObject that its RexPhysics component has encountered a collision, and passes it the collider it collided with, the side it encountered the collision on, and the type of collision. It’s designed to be overridden by specific RexObjects so you can set unique effects to occur with various collisions; a simple example would be playing a particle effect when the object collides with a wall.

An attached RexPhysics component will automatically call this method if you have slotted this RexObject into its Rex Object slot.

public virtual void Clear()

This calls Destroy() on the object.