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

Public Methods

public void SetPosition(Vector2 position)

Sets the position of the object, including updating the attached JetController and JetPhysics if applicable. This is the preferred way of programmatically changing the position of an object in JetEngine, since JetPhysics 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 JetObject 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 JetObjects if you need them.

public virtual void OnGravityScaleChanged(float _gravityScale)

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

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

This notifies the JetObject that its JetPhysics 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 JetObjects 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 JetPhysics component will automatically call this method if you have slotted this JetObject into its Jet Object slot.

public virtual void Clear()

This calls Destroy() on the object.