126

Share

GAME DEVELOPMENT

What Are 2D Effectors In Unity?


When game object colliders collide with each other, effector 2D components are used with collider 2D components to direct the forces of physics in a project.

Agnesh Pipaliya

June 30, 2022

Games are always a good source of entertainment and can sometimes work as an educational tool. Especially for children, learning with fun is a great experience. On the other hand, the elderly can learn as well as get a short break from their busy working schedule.

But are you aware of the game effects? 

Effects are used in every game to make it more attractive than others. Effector 2D is one of the tools used for it. In this blog, you will discover what they are and how you can use them. 

Types Of Effectors 2D

  • PlatformEffector2D
  • SurfaceEffector2D
  • PointEffector2D
  • BuoyancyEffector2D
  • AreaEffector2D

PlatformEffector2D

Use of PlateFormEffector2D: The PlatformEffector2D allows us to create platforms and 2d games which characters can pass through when jumping from underneath them and then land on top once they’re above.

Steps To Make PlateformEffector2D

Step 1 - Create an empty game object, ex. I have a name with “player”.

Step 2 - Add spriterenderer to add character type sprite, then add box collider 2d and rigidbody 2d.

Step 3 - Create one more empty game object, ex. I have a name with a platform with sprite renderer, box collider 2d, and PlateformEffector2D.

NOTE: You make sure that the Colliders you use with the effector would not be set as triggers so that other colliders can collide with it and the “Used By Effector” is must be true for a 2Dcollider on the game object on which we apply PlateformEffector2D.

 

 

 

 

Properties And Its Function

 

 

Use One Way - When this is True the character will be able to pass from underneath the platform through it and land on top of platform collider.When this option is off or set false they will collide with the underside of the platform.

 

 

 

 

 

Use One Way Grouping - This is useful when multiple colliders are used on the object passing through the platform and they all need to act together as a group.

Surface Arc - The angle of an arc centered on the local ‘up’ it defines the surface which doesn’t allow colliders to pass.

 

 

Use Side Friction And Use Side Bounce - determine whether friction or bounce parameters of the current physics 2d material will be applied to the side of the platform when character collide with it.

SurfaceEffector2D

Use of SurfaceEffector2D: You can use the SurfaceEffector2D to Create conveyor belts behavior.

Steps To Make SurfaceEffector2D

Step 1 - apply SurfaceEffector2D, rigid body 2d and box collider 2d on a game object that you want to make it like conveyor, ex. I have a name with “tile”.

Step 2 - apply rigidbody 2d and box collider 2d on a game object that you want to make a move on SurfaceEffector2D.

 

 

Step 3 - set all game object that we want to move on surface effector above game object having surface effector 2d as shown below image.

Step 4 - Now run the seen and you see when collision occurs between target collider and surface effector, the target game object move on game object having surface effector.

 

 

NOTE: You make sure that the Colliders you use with the effector would not be set as triggers so that other colliders can collide with it and the “Used By Effector” is must be true for a 2Dcollider on the game object on which we apply SurfaceEffector2D.

 

 

Properties And Its Function

 

 

Use Collider Mask - If you use mask, else the global collision

Matrix will be used as the default for all colliders.

Collider Mask - Use for to select specific layers allowed to interact with the effector.

Speed - The speed you want to be maintained within the surface.

Speed Variation - Use for random variate the speed on the surface between 0 to speed variation value, If negative value applied , a random reduction in the speed will be applied.

Force Scale - Force scale property allows us to scale the force being added to objects in contact with the surface effector 2d at a value of zero no force will be applied at a value of one the force being applied by the surface effector will oppose any other forces being applied to the object.

Use Contact Force - Use for add force at the moment when target collider and surface collider 2d collide with each other. This force is applied at the point of contact between the surface and the target collider so this will cause the object being rotated.

Use Friction - Use When You Want To Add Friction When Contacting The Surface.

Use Bounce - Use When You Want To Add Bounce Force When Contacting The Surface.

PointEffector2D

Use of PointEffector2D: Point effector apply as forces to either attract or repulse against a certain point.

Steps To Make PointEffector2D

Step 1 - For understanding this effector I have one game object name asteroid with sprite renderer, circle collider 2d, and rigid body 2d. Set its gravity scale zero so it hangs at that point.

 

 

Step 2 - Add one more circle collider 2d and make its radius large as shown in the below image. and set its trigger true and used by effector true.

Step 3 - Add pointer effector, now the force magnitude is, of course, the amount of force that you want to apply and this is negative if you want it to attract and positive if you want it to repulse.

 

 

Step 4 - Make a duplicate of this asteroid and move it as shown image and run scene, we should see they quickly repulse if force magnitude is positive with each other.

Properties And Its Function

Force Magnitude - The Magnitude Of The Force To Be Applied.

Force Variation - The Variation Of The Magnitude Of The Force To Be Applied.

Distance Scale - The Scale Applied To The Distance Between The Source And Target.

Drag - The Linear Drag To Apply To Rigid-Bodies.

Angular Drag - The Angular Drag To Apply To Rigid-Bodies

Force Source - The Force Source Is The Point That Attracts Or Repels Target Objects. The Distance From The Target Is Defined From This Point.

Collider - The Source Point Is Defined As The Current Position Of The Collider.

Rigidbody - The Source Point Is Defined As The Current Position Of The Rigid Body.

Force Target - The Force Target Is The Point On A Target Object Where The Effector Applies Any Force.

Collider - The Target Point Is Defined As The Current Position Of The Collider.

Rigidbody - The Target Point Is Defined As The Current Center-Of-Mass Of The Rigid Body.

Force Mode - Shows How The Forces Are Calculated.

Constant - It Ignores The Distance Between Source And Target.

Inverse Linear - The Force Is Applied As A Function Of The Inverse-Linear Distance Between The Source And Target. When The Source And Target Are In The Same Position Then The Full Force Is Applied But It Falls-Off Linearly As They Move Apart.

Inverse Squared - The Force Is Applied As A Function Of The Inverse-Square Distance Between The Source And Target. When The Source And Target Are In The Same Position Then The Full Force Is Applied But It Falls-Off Squared As They Move Apart. This Is Similar To Real-World Gravity.

BuoyancyEffector2D

Use of BuoyancyEffector2D: You can use the Bounce Effector 2D to Create simple fluid behavior such as floating and the drag and flow of fluid.

Steps To Make BuoyancyEffector2D

Step 1 - To understand BuoyancyEffector2D, I have a game object name with “water” with sprite renderer, box collider 2d and rigid body 2d and one other game object name “asteroid” with sprite renderer and circle collider and rigid body 2d.

 

 

Step 2 - Now I just add buoyancy effector 2d on my “water” game object and make its collider as a trigger and used by effector true or say enable.

 

 

Step 3 - Run the scene and you can see your game object that you want to flow or float is really floating on buoyancy effector surface

 

 

Properties And Its Function

 

 

Density - indicates the density of the Buoyancy Effector 2D fluid. This affects the behavior of Collider 2Ds: Those with a higher density sink, those with a lower density float, and those with the same density appear suspended in the fluid.

Linear Drag - Use to affecting the positional movement of a GameObject. This only applies when inside the fluid.

Angular Drag - The drag coefficient affecting the rotational movement of a GameObject. This only applies when inside the fluid.

Flow Angle - The world-space angle (in degrees) for the direction of fluid flow. Fluid flow applies buoyancy forces in the specified direction.

Flow Magnitude - The “power” of the fluid flow force. Combined with Fluid Angle, this specifies the level of buoyancy force applied to GameObjects inside the fluid. The magnitude can also be negative, in which case the buoyancy forces are applied at 180 degrees to the Flow Angle.

Flow Variation - Enter a value here to randomly vary the fluid forces. Specify a positive or negative variation to randomly add or subtract from the Fluid Magnitude.

AreaEffector2D

Use of AreaEffector2D: Area effector 2d is used to apply forces within an area defined by the attached collider 2Ds when target collider 2D comes into contact with each other.

Steps To Make AreaEffector2D

Step 1 - To understand area effector 2d , I’m just create one game object name “player” with sprite renderer, rigid body 2d,box collider 2d and other game object name “Effector” with sprite renderer ,rigid body 2d, box collider 2d and area effector and make its collider as trigger and used by effector true or say enable.

 

 

Step 2 - Create another game object name “Effector” with spriterenderer, rigidbody 2d, box collider 2d and area effector and make its collider as a trigger and “Used By Effector” true or say enable.

 

 

Step 3 - Now add Force magnitude as you want, i’m just adding 50 and run the scene, you will see when target collider trigger out from area effector collider gets force in the positive direction.

 

 

Properties And Its Function

 

 

Force Angle - The angle of the force to be applied. For example, if we set force angle 50 then the game object passes through the area effector gets 50-degree directional force. See below image for example:

 

 

Force Magnitude - The magnitude of the force to be applied.

Force Variation - The variation of the magnitude of the force to be applied.

Drag - The linear drag to apply to Rigidbody 2Ds.

Angular Drag - The angular drag to apply to Rigidbody 2Ds.

Force Target - The point on a target GameObject where the Area Effector 2D applies any force.

Collider - The target point is defined as the current position of the Collider 2D. Applying force here can generate torque (rotation) if the Collider 2D isn’t positioned at the center of mass

Rigidbody - The target point is defined as the current center-of-mass of the Rigidbody 2D. Applying force here will never generate torque.

Conclusion:

This is a comprehensive guide to using Effector 2D. Each type of Effector 2D is explained here in detail with graphics. Try to learn this tool and start developing your game projects with it, or you can take the help of a game development company.

 

img

Agnesh Pipaliya

COO of Vasundhara Infotech, a leading Software development company in the USA. His technological interests has helped the company in making useful decisions.

message

Have a project in mind? Drop a message to Bansi Pipaliya & start the discussion!

Get a Newsletter

Sign Up to our newsletter to get latest updates staight in your inbox.

Vasundhara respects your privancy. No Spam!

Get a Newsletter

Sign Up to our newsletter to get latest updates staight in your inbox.

Vasundhara respects your privancy. No Spam!

message

Have a project in mind? Drop a message to Bansi Pipaliya & start the discussion!

Latest 13 Web Development Trends To Expect In 2022
April 11, 2022 Category : company news

Revealing Vasundhara’s New Identity

Read More
Leave a Comment