As an Associate of different 3rd parties, this website earns from qualifying purchases & contains affiliate links: learn more in the footer.

Throw Control — Unity Asset

Throw Control (Unity Asset) — highly customizable Advanced Throwing System for Unity. You can throw any object forward or in any direction with custom force, a center of mass, and 80+ other throwing parameters. 3 Modes. 4 Demos. 11 Throwing Objects.

Unity Asset Store — Download Button

Features of Throw Control

All modules are designed independently to keep the Unity Asset extendable & easy to understand:

  • Cross-platform (Mobile, Desktop) Throwing with 3 Modes:
    • “Click Or Tap” (Easy),
    • “Flick” (or Swipe: Hard),
    • “Press Key” (Easy).
  • Device Orientations: Portrait, Landscape.
  • 80+ Customizable Parameters — sensitivity, force, torque, delays, position, rotation, fading, etc.:
    • for all Throwing Objects at once;
    • for each Throwing Object individually.
  • 4 Demos: Mobile, Desktop.
  • 7 Events.
  • 11 customized Throwing Objects:
    • Weapons: Axe, Sword, Broken Sword;
    • Balls: Basketball, Brick Balls (Grey, Red), Football;
    • Miscellaneous: Coin, Shovel, Horseshoe, Tree/Branch.
  • Easy implementation of your own Throwing Objects.
  • Dynamic Sound System — play Sounds based on speed, pitch, and volume factors of Throwing Objects upon:
  • Dynamic Material System:
    • Fading In & Fading Out: Dissolving,
    • Material Changing in Runtime for Any Custom Game Logic (e.g., fail, win).
      Examples: Basketball (docs), Football (docs).
  • Layer Changing (to avoid unwanted collisions).
  • Optimizations:

Package Contains

  • 2 Cross-Platform Demo Scenes with Static Camera (Modes: “Click Or Tap”, “Flick”).
  • 1 Desktop FPS Demo Scene with Controls: Walk, Run, Jump, Throw (Mode: “Click Or Tap”).
    • It also works on Mobiles without Controls: Walk, Run, Jump. Throwing and Camera Rotation are executed simultaneously.
  • 1 Desktop Demo Scene (Mode: “Press Key”).
    • It also works on Mobiles with a separate Throwing Mode that you can indicate in the Editor.
  • Menu Scene.
  • Loading Screen to switch scenes seamlessly.

Check the Map of Unity Assets to choose the product that best suits your needs.

Package is a Part of Unity Assets

Football (docs).


Basketball Game (docs).


Use Cases


Throwing System: 80+ Customizable Parameters

Throwing System consists of 4 control scripts that are completely customized already in Demo Scenes.

1. Random Object Pooler

RandomObjectPooler.cs — independent script: Object Pool, performance optimization technique through Objects Reusing. It’s used by ThrowControl.cs. All Throwing Objects are created at the Scene Start from prefabs and used throughout the Scene Session.

2. Throw Control

ThrowControl.cs — main script that manages the Throw & all Throwing Objects on a scene through Object Pool. The script uses disabling and enabling the following nodes: Colliders, Triggers, Renderers.

To Get the Count of Throwing Objects, use GetObjectCount() function.

Throwing Modes

You can Assign the Throwing Modes for Desktop and Mobiles separately starting from v6.0.

The higher the last position of the mouse cursor (or finger) during the click (or tap, or key press), the greater the strength of the throw. Throwing System completely works on Desktop as well as on Mobiles.

I. Click Or Tap

In this mode, the Game Object is thrown in the direction of the click (desktop) or tap (mobile).

FPS

For the First-Person Shooter game, there is an option for fixing the input position in a specific place on the screen (by default in the center of the screen). FPS Desktop Demo uses CharacterController (Throw force takes into account the speed of the player’s movement).

II. Flick

In this mode, you can throw object in the style of the Pokemon GO game (iOS, Android) (by flicking it from the bottom of the screen up toward the target).

Is Full Path For Flick?

If it’s false, then it allows fast flicks only: positions in the last and previous frames are taken into account.

III. Press Key

This mode is similar to Click Or Tap mode, but the Throw happens after pressing the Target Key on the Keyboard. Tested with Desktop Platforms only.


Work Scheme

  1. Initialize Object Pool,
  2. Initialize Throwing Objects,
  3. Get First Throw (Start the Throwing Cycle):
    1. Get Next Throw,
    2. Fade In,
    3. Throw,
    4. Fade Out,
    5. Reset.

Events

  • OnInitialized;
  • Next Events have ThrowingObject as a parameter. So you have more flexibility with access to instances of ThrowingObject.cs in outer functions assigned to Events.
    • OnNextThrowGetting,
    • OnThrow,
    • OnFadingOut,
    • OnReset.

Coroutines

The only script that starts coroutines. Because of coroutines behavior, it’s impossible to place some methods inside ThrowingObject.cs. OOP doesn’t work in this case, but we have a stable throwing with Object Pool.

3. Throwing Object

ThrowingObject.cs — script that contains basic functions and parameters to operate Throwing Object.
This script must be attached to each Throwing Prefab (check tutorial).

Events

  • OnThrow;
  • OnResetPhysicsBase.

Parameters

  • flagCustom: for Any User Logic outside the Throwing System.
  • monoBehaviourCustom: it’s useful to assign a specific control script for a unique type of Throwing Object and access to it outside the Throwing System.
    Example: BasketballBallControl.cs in Basketball (docs); Football (docs).
  • positionInViewportOnReset: spawn position [x, y].
  • cameraNearClipPlaneFactorOnReset: spawn position [z].
  • audioDataCustom: array for customizing any dynamic Audio Data based on speed, pitch, and volume factors of Throwing Object. Access from ThrowControl.cs or ThrowingObject.cs with PlayRandomSoundDependingOnSpeed() function:
    • 0 Element is used for Throw Audio (Whoosh).
    • Other Elements can be used for any Custom Game Logic (e.g., for Customizing Collisions with different surfaces (floor, wall, etc.). Examples of using outside the Throwing System dynamically and uniformly: Basketball (docs), Football (docs).

Colliders

Rotation (Torque) & Center of Mass

There are some nuances with Rigidbody.centerOfMass when rotation.

Symmetric Mesh

If you use Mesh Collider for Throwing Game Object and your mesh is ideally symmetric, then it’s the perfect case and the game object will throw naturally.

Asymmetric Mesh

If you use Mesh Collider for Throwing Game Object and your mesh is asymmetric, then you will have unnatural throw behavior when rotation.

Solutions:

1. Custom Center of Mass. You can indicate Custom Center of Mass manually in the Editor. Unity Package contains some examples with Custom Center of Mass and Tools for Debugging it Visually (you can also turn on the Gizmos in the Game view to facilitate the debugging). There is no magic function that calculates the right Center of Mass.

2. Simple Forms of Colliders. You need to use one or more simple forms of colliders (box, sphere, etc.) placing them on the same Throwing Game Object and along the straight line. So in this case, you will have the right center of mass & right rotation.

Convex Mesh

Unity allows you to use only convex mesh colliders. In some cases, it is not what you need because the collider by default can cover more space than the object itself in some points. In order to quickly & automatically get a convex mesh collider for complex objects, use Technie Collider Creator.

4. Material Control

MaterialControl.cs — an independent script that implements Fading (Dissolving) VFX for Throwing Objects: it’s used by ThrowingObject.cs. You can use it for Fading outside Throwing System (Examples: Ring, Ring Holder, Net, Backboard, Pole in Basketball Game (docs)).

Here you can control Fading In & Fading Out with Full Control of Value, Delay, Time & Speed for Indicated Shader Parameter. Actually, you can change any Float Parameter in the shader over time.

Default Materials for Throwing Object is still placed in the Mesh Renderer component.

Parameters

  • materialDataCustom – array for Customizing Material Changing for Any Custom Game Logic (e.g., fail, win). Access from ThrowControl.cs or ThrowingObject.cs with SetMaterial() function.

    SetMaterial() function is used instead of Color Changing with SetColor() function to avoid memory allocations. So if you plan to change the Colors of Throwing Objects in the Runtime outside the Throwing System, you need to create Materials with Target Colors in advance.

    Examples with using outside the Throwing System dynamically and uniformly:
    Basketball (docs), Football (docs).

Shaders

There are 3 Custom Shaders with “Slice Guide” Texture for Fading of Game Object and its Shadow.
Check [Your Material] > Shader > Custom > Makaka Games:

  • Diffuse (Dissolving),
  • Bumped Diffuse (Dissolving),
  • Particles Cutout Transparent — for Transparent Textures
    (Example: Net in Basketball (docs), Football (docs)).

Tutorial

This tutorial is relevant for Throw Control 6.0+.
Tutorial for the previous version can be found only in the asset folder.

Getting Started with Throw Control

Folders & Files in the package by default:

  • Makaka Games.

Steps

If you have any issues with the first launch then just Reach Support with Invoice Number and Get Help.

If you read this tutorial from PDF, first check the latest docs online to get actual information.

  1. Create New Unity Project with Unity 2022.3.20 & “3D” Template.
  2. File > Build Settings > Windows, Mac, Android, iOS, WebGL > Switch Platform.
  3. Download and import Throw Control into Unity.
  4. Window > TextMeshPro > Import TMP Essential Resources.
  5. Open Scene: Makaka Games > Throw Object 3D > Scenes > Menu.
  6. File > Build Settings > Add Scenes to build:
    • Menu,
    • LoadScreen (from Makaka Games > Publisher > Everyday Tools > SceneControl > Scenes),
    • Demo_ThrowObject3D_Desktop_FPSController,
    • Demo_ThrowObject3D_Desktop_Mobile_Static_Tap,
    • Demo_ThrowObject3D_Desktop_Mobile_Static_Flick,
    • Demo_ThrowObject3D_Desktop_Mobile_Static_PressKey.
  7. Edit > Project Settings > Audio > DSP Buffer Size > Best Latency.
  8. Customize Layer Changing (to avoid unwanted and mutual collisions):
    1. Edit > Project Settings > Tags and Layers > Layers
      (use Recommended Names and Numbers, or read the instructions below in this list):
      • User Layer 8: ThrowingObject,
      • User Layer 9: NoCollisionsInLayer.
    2. Edit > Project Settings > Physics (and also Physics2D) > Layer Collision Matrix:
      • ThrowingObject: customize as you want, or use your any existing layer instead.
      • NoCollisionsInLayer: uncheck all.
    3. Reopen Unity Project.
    4. Option: If you can’t customize layers with recommended numbers, then use other empty numbers and assign them in each demo scene in the Hierarchy window:
      ThrowingPoolControl: ThrowControl.cs > Layer Changing:
      • Layer On Init > NoCollisionsInLayer,
      • Layer On Throw > ThrowingObject,
      • Layer On Reset > NoCollisionsInLayer.
  9. Option: If you use plugins for issue finding in your project like Maintainer, add this path for ignoring: Makaka Games/Throw Object 3D/Physic Materials/Meshes for Colliders/
    (they were created with Technie Collider Creator which is not needed for Throw Control, but it has source files for editing).
  10. Test in the Unity Editor or Build for Mobile or Desktop.

Creating your own Throwing Object Prefab

  1. Create Prefab with a template:
    1. Drag one of the customized Throwing Object prefabs from the Project window into the Scene view,
    2. Name your Game Object,
    3. Drag the named Game Object into the Project window to create the Original Prefab.
  2. Select the Game Object on the Scene & Customize it:
    1. Indicate Mesh of your 3D Model in Mesh Filter component,
    2. Customize Material in Mesh Renderer component (duplicate previous Material in the Project window and indicate here to separate different Throwing Objects),
    3. Customize Fading in Material Control component,
    4. Customize Colliders:
      1. Indicate Mesh in Mesh Collider component (or in more suitable collider component);
    5. Option: Customize the Center of Mass for more natural Throwing.
  3. Customize the Transform component as you wish.
  4. Apply Changes to Prefab.
  5. Delete Game Object from Scene.
  6. Option: Add Asset Label (ThrowingObject) for Prefab for convenient searching in the Project window.
  7. Add Prefab to Random Object Pooler component of ThrowingPoolControl Game Object.
  8. Throw Object Forward in “Play Mode”.

How to Keep Game Objects in Scene after the Throwing?

Here is the result video after applying manipulations in this section.

By default, Throwing Objects are not destroyed during the game due to Object Pool pattern with Object Reusing. Initially, the system is designed so that objects disappear after a certain time to save your device’s memory. Note that objects in pool are instantiated in advance, before you can click start button.

You can achieve the desired result by setting a large number of objects in the pool and a large reset delay, while disabling the fading:

  1. Target Throwing Object prefab > Material Control component > Is Parameter Changing On At Start > Uncheck (we are disabling the fading here).
  2. ThrowingPoolControl Game Object on Scene:
    1. Random Object Pooler component > Init Pooled Amount (set to target amount of objects in pool, e.g. 99);
    2. Throw Control component > Reset Delay (set to target amount of seconds: 999).

The system is designed with the Object Pool pattern, so you can’t set these values in inspector to protect you from too large values, long loading at start & low performance of your game, but you can fix the restrictions inside the script in field attributes.

Testing

You can quickly test in Unity Editor or with Unity Remote.

WebGL

Learn the Article called WebGL and Unity about Building and Testing Unity games and apps for WebGL.

Tested with Platforms

  1. Mobile Platforms:
    • iOS on iPhone XS Max;
    • Android on Samsung Galaxy A71;
    • WebGL in Google Chrome.
  2. Desktop Platforms:
    • Windows;
    • macOS;
    • WebGL in Google Chrome.

Support

First, read the latest docs online.
If it didn’t help, get the support.

Changelog

Check the current version of Throw Control on Asset Store.
The latest versions will be added as soon as possible.

6.0:

Features:

  • New Throwing Mode for Desktop using Keyboard called “Press Key” (in addition to Mouse only) with 2 Ways that form speed and throw direction based on:
    • current input position of Mouse (last position of mouse cursor),
    • fixed input position (doesn’t depend on the mouse). It’s suitable for FPS.
  • WebGL Support via HTTPS for Mobiles: iOS & Android. Learn WebGL Tutorial.
  • New Throwing Object: Football ball.

Improvements:

  • Unity 2022.3.20.
    • Watch some part of the DevLog during upgrading from Unity 2021.3: English, Russian.
  • Asset is downloaded into your project as a Tool/Plugin now (not as a Complete Project), which is more flexible. Read “Getting Started” Tutorial to Import correctly.
  • Assigning Throwing Modes for Desktop and Mobiles separately.
  • Detailed Tutorial Screens for 4 Demo Scenes.

5.2:

Features:

  • Opportunity to Set a target prefab/prefabs of Throwing Objects before Initialization outside Throwing System with the next functions of ThrowControl.cs (it’s used in AR Basketball (docs) due to different ball prefabs for different AR Engines: AR Foundation & AR Camera Lite (docs)):
    • public void SetPrefabBeforeInit(GameObject gameObject),
    • public void SetPrefabsBeforeInit(GameObject[] gameObjects).

Improvements:

5.1:

Improvements:

  • Unity 2021.2.16.
  • Opportunity to use a Target Audio Source when Playing Sounds from audioDataCustom related to Throwing Object with public void PlayAudioRandomlyDependingOnSpeed(int index, bool isStoppedBeforePlay, AudioSource audioSource = null) & ThrowingObject.cs.
    Example: Basketball (docs), Football (docs).

5.0:

Features:

  • Dynamic and Unified Operating of Data for Different Throwing Objects (examples with using outside the Throwing System: Basketball (docs), Football (docs):
    • audioDataCustom – Array for Customizing Collisions with different surfaces (e.g., floor, wall) or for Any Custom Game Logic; merged with deprecated Whoosh Audio. Access from ThrowControl.cs or ThrowingObject.cs with PlayRandomSoundDependingOnSpeed() function.
    • materialDataCustom (MaterialControl.cs) – Array for Material Changing for Any Custom Game Logic (e.g., fail, win). Access from ThrowControl.cs or ThrowingObject.cs with SetMaterial() function.
  • RandomObjectPooler.cs: Split areRandomizedObjects boolean flag into 2 flags:
    • areRandomizedObjectsWhenCreating – when you need a random instance count of possible Throwing Object prefabs every Scene Start.
    • areRandomizedObjectsWhenGetting – when you require a random Throwing Object instance for every Throw.
  • Retrieving Count of Throwing Objects with ThrowControl.cs > GetObjectCount().
  • Tools for Debugging the Center of Mass Visually in Unity Editor. If the Center of Mass by Default is not correct, you can use these tools for improving Center of Mass with Custom value.

Improvements:

  • Unity 2021.2.13.
  • Instantiating Throwing Objects at Start outside the Game Area in target positionAtInit (RandomObjectPooler.cs) — Avoid Collisions between Throwing Objects and with Other Physical Objects more accurately:
    • Split Reset of Position:
      • On Init – to Target Position at Instantiating.
      • On Throw – to Camera Position.
    • Split Layer Changing option into 2 stages & 3 states:
      • On Init,
      • On Throw & On Reset.
  • Consolidating the Same Code of Registering Throwing Object in Throwing System into RandomObjectPooler.cs.
  • ThrowControl.cs > OnInitialized() Event is raised more accurately: in the correct frame after all operations.
  • Shovel Throwing Object: Custom and Accurate Collider for Shovel.
  • Unified Menu Scene for All Scenes.
  • Loading Animation for Start Buttons.

4.4:

  • Unity 2021.1.20;
  • New Flag: “Is Throwing Blocked When Clicking UI”;
  • Improve Project Settings to modern standards of New Unity Project;
  • Fix Resetting Rotation & Position from RigidBody to Transform to be compatible with AR Foundation camera (for AR Throwing (docs));
  • Fix Secondary Throw in “Flick” Mode when clicking on current Throwing Object after throw and before appearing of new throwing object;
  • Fix Throwing in “Flick” Mode when clicking outside any object with Collider after correct flicking throw;
  • Fix Throwing in “Flick” Mode when !isFullPathForFlick: clicking on empty space doesn’t cause throwing now;
  • Fix “NullReferenceException” when “None” Game Object is assigned in Inspector of Random Object Pooler;
  • Fix Missing Textures.

4.3:

  • New Platform: WebGL Support (Tested in Google Chrome);
  • Unity 2021.1.12;
  • Fix Dissolving VFX.

4.2:

4.1:

  • Unity 2021.1.6.

4.0:

This version adds performance improvements by more effective handling of materials, shaders, fading & caching, so it’s incompatible with previous versions of Asset.

  • Improve Dissolving (Fading) VFX. Separate Independent Script for Throwing Objects: MaterialControl.cs — so you can use it for Fading outside Throwing System (Examples: Ring, Ring Holder, Net, Backboard, Pole in AR Basketball GO (docs) & Basketball Game (docs)).
    • 1 Material Instead of 2: No Memory Allocation while Fading.
    • 3 Custom Shaders with Shadow Fading & “Slice Guide” Texture for Fading:
    • Fading In & Fading Out with Full Control of Value, Delay, Time & Speed for Indicated Shader Parameter.
  • Add public event Actions for Each Trowing Object in ThrowingObject.cs:
    • OnThrow;
    • OnResetPhysicsBase.
  • Improve all public Events in ThowControl.cs: add ThrowingObject as a parameter. So you have more flexibility with access to instances of ThrowingObject.cs in outer functions assigned to Events.
  • Add a Custom MonoBehaviour field in ThrowingObject.cs: it is useful to assign a specific control script for a unique type of Throwing Object and access to it outside the Throwing System. Example: BasketballBallControl.cs in AR Basketball GO (docs) & Basketball Game (docs).
  • Now SetMaterial() function is used instead of SetColor() functions all over the system to avoid memory allocations. So if you plan to change Colors of Throwing Objects in Runtime outside Throwing System you need to create Materials with Target colors in advance. Example: Red Fail Material in AR Basketball GO (docs) & Basketball Game (docs).
  • Unity 2019.3:
    • Fix Mesh Collider of Horseshoe.

3.17:

  • AudioData class and PlayRandomSoundDependingOnSpeed() function. Now you can easily declare Sound Settings in your own scripts to Play Sounds based on the speed of Throwing Objects. It’s helpful when you implement a dynamic sound system when Throwing Objects collide with Floor, Walls and Other Game Objects.
  • Function: public int GetObjectCount ();
  • Function: public void SetColor (Color color, GameObject to);

3.16 (Bug Fixing):

  • Audio Delay (Latency) on Mobiles;
  • “Index Out of Bounds” error in Input.GetTouch(0) for Mobiles;
  • Debug.LogWarning() for unknown platforms.

3.15:

  • Option: Custom Flag in ThrowingObject.cs for Any User Logic.

3.14:

  • Option: Tag Selector for ThrowControl.cs to set a custom tag for all objects in the pool.

3.13:

  • Unity 2019.1;

3.12:

  • Unity 2018.3;

3.7:

  • Move cameraNearClipPlaneFactor to ThrowingObject.cs to customize the whole position (X, Y, Z) of Throwing Object prefab in one place;
  • Fix enabling and disabling colliders for compound Throwing Prefabs.

3.6:

  • Unity 2018.2;
  • Fix errors: When Flick Mode you just click on the object without finger position change.

3.4 (Layer Changing in Throw Control):

Actual for quick Throwing to neutralize mutual collisions.

  • Customizations:
    • ON / OFF,
    • Layer Mask on Throw,
    • Layer Mask on Reset,
    • Delay.

3.3 (Throw Customizations in Throw Control):

  • Input Sensitivity,
  • Force Factor Extra,
  • Torque Factor Extra,
  • Torque Angle Extra,
  • Parent on Throw.

3.2 (“Flick” Mode Customizations in Throw Control):

  • Option: Is Full Path:
    • If it’s false then it allows fast flicks only (positions in the last and previous frames are taken into account);
  • Lerp Time Factor On Touch.

3.1:

  • FPS Demo integrated with CharacterController (Desktop);
  • Throw force takes into account the speed of the player’s movement;
  • Fixing an input position in a specific place on the screen (by default in the center of the screen).

3.0 (New Architecture: Throw Control):

Main Control Script (Throw Control) operates Object Pool & All Throwing Objects now (Throwing Object Script is attached to each Throwing Object prefab).

Work Scheme:

  1. Initialize Pool,
  2. Initialize Throwing Objects,
  3. Get the First Throw,
  4. Get Next Throw.
  • Customizations in Throw Control:
    • Throw Mode;
    • Events with Delays:
      • OnInitialized,
      • OnThrow,
      • OnNextThrowGetting,
      • OnReset,
      • OnFadeOut.

2.6 (Rotation Customizations):

  • Option: Rotate Object in Throw Direction;
  • Rotation on Reset:
    • Default,
    • Last,
    • Random,
    • Custom.

2.5:

  • Position in Viewport On Reset.

2.4 (Center of Mass Customizations):

  • Custom Center of Mass,
  • Logging of Center of Mass by Default.

2.3 (Torque Customizations):

  • Torque Axis,
  • Torque Angle,
  • Torque Factor,
  • Max Angular Velocity at Awake.

2.2 (Force Customization):

  • Force Factor,
  • Force Direction Extra.

2.1:

  • “Click or Tap” Throwing Mode  for Desktop & Mobiles;
  • Customization:
    • Throwing Mode.

2.0 (Object Pool — Throwing of Multiple Objects):

  • Prefabs Using:
    • Single (actual for Testing target prefab; None => Multiple),
    • Multiple;
  • Generation order for Multiple Prefabs:
    • In random order,
    • In the right order;
  • Customizations:
    • Pool Parent,
    • Init pooled amount,
    • Event (OnInitialized).

1.3 (Dynamic Sound System):

Sound System depending on Speed of Throwing Object.

  • Customizations:
    • Array for randomly selecting Sounds,
    • Speed Clamping,
    • Pitch (Minimum & Factor),
    • Volume Factor.

1.2 (Fade Out option for Thrown Objects):

  • Customizations:
    • ON / OFF,
    • Delay,
    • Speed,
    • Materials,
    • Event (OnInitialized).

1.1:

  • Desktop version: throw object with the mouse. Use it for Standalone apps or for testing of mobile apps in Unity Editor.

1.0 (“Flick” Throwing Mode for Mobiles):

Unity Assets

Support for Unity Assets

I am Andrey Sirota, Founder of Makaka Games and full-time Publisher on the Unity Asset Store. First, read the latest docs online. If it didn’t help, get the support.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

Back to top button