How to use Unity3D game engine to create an Electromagnetism Experiment Simulation?

Problem statement

Experiments based on the phenomena of electromagnetism must be very precisely performed in order to get the desired results. Traditional electromagnetism experiments have many shortcomings. This paper uses the Unity3D game engine to create an electromagnetism experiment simulation that includes three electromagnetism experiments: static charge, electrostatic induction, and the earth’s magnetic field. Furthermore, this study develops a software library for electromagnetism experiment simulation that can be applied to different electromagnetism simulation experiment systems. In this way students will be able to understand the phenomena of electromagnetism in a more detailed and fun way.


Electromagnetism is a very essential part of physics. In physics, things must be taught to students practically as well as theoretically in order for them to understand things in a better way. Just like other concepts of physics, electromagnetism must also be taught with practical demonstration. Simulation based experiments of electromagnetism on unity 3d game engine is a very revolutionary concept. Using it, we can perform as much experiments as we want under whatever conditions desired. The traditional method has certain shortcomings.

1: In order to perform electromagnetism experiments in a traditional way, a physical lab is required which is quite costly.

2: Electromagnetism experiments require electricity as a power source thus it may prove to be dangerous for students who are inexperienced.

Game is a revolutionary platform for simulating natural processes, operations, and occurrences. Most significantly, games can give a high level of involvement, which is critical for learning. Many educators and teachers are enthusiastic about employing video games in the classroom. Using game-based modelling, this research proposes a novel technique to replace classic electromagnetism tests. We developed an instructional game using the Unity3D game engine, which creates a virtual electromagnetism experiment laboratory. Students can perform several electromagnetism experiments in this game, just as they would in a real laboratory, but more conveniently and safely.


Now we will be simulating some of electromagnetism experiments using unity 3d game in order to understand in a better way that why it is an efficient method for performing experiments. Unity3D game engine.


  1. Static Charge Simulation:

The electrostatic charge is an inactive charge that is in a state of dynamic equilibrium. According to the electrostatic theory, like charges repel each other and unlike charges attract each other.

dynamic equilibrium of electrostatic charge
dynamic equilibrium of electrostatic charge

Static Charges must be nested in Game Object, which is a basic component offered by U3D in order to replicate the electric field of an electrostatic charge. In order to avoid charge interpolation and improve the realism of electromagnetic simulations, collision components and rigid body in unity are necessary. NVIDIA’s PhysX physics engine is used by Unity. NVIDIA graphics cards are used in many PC games. The cards are made for games and can be used to imitate real-world physical consequences. Naturally, it can also be used to simulate electromagnetism experiments. A collider must be attached to the Game Object in order for it to feel the collision. Basic body colliders (Box, Sphere, Capsule, Cylinder), Mesh Collider, Wheel Collider, and Terrain Collider are all available in Unity. The electrostatic charge can be wrapped in a Sphere, and then the Sphere Collider and rigid body can be added.

  1. Electrostatic Induction Simulation:

Electrostatic induction is the technique of creating or producing electricity in a substance by bringing an electrically charged object close to it. It causes the charges in that material to be reallocated. As a result, one side of the material has too many positive charges, while the other has too many negative charges. For example, we often feel in winters that static electricity is produced whenever we take our sweaters off. Another example is of pieces of paper getting attracted on scale after we rub the scale for a while on our hair.

The principle of electrostatic induction arises from the proximity of a charged object to an uncharged conductor. Because of the interaction of charges, the charge inside the conductor will be redistributed at this time. It is the attraction of various types of charges to the vicinity of charged objects. While the same charge is repelled to the opposite end of the conductor away from the charged object, an equal amount of dissimilar charges appear at both ends of the conductor. This is known as electrostatic induction. The Van de Graaff generator is a type of electrostatic high voltage device that can generate over 100 million volts, as illustrated in Figure shown below.  Furthermore, people are always surprised by this device’s interesting electrostatic phenomena, such as “lightning” or their hairs that erect when they touch the hollow spherical smooth balls.

Van der Graf motor
Van der Graf motor

The Van der Graf motor is the most important model for simulating the phenomenon of electrostatic induction. A piece of cloth, four balloons, a metal sphere, and a particle accelerator capable of emitting particles are also required. Figure shown below depicts the initial scene.

initial scene of electrostatic induction experiment
initial scene of electrostatic induction experiment

To begin, add all of the models as Game Objects with Rigid body and Collider properties. As a result, when the experiment simulation runs, these models do not appear to fall into the terrain or penetrate each other. Then, for each balloon, the van der Graf electric motor, and the metal ball, we add an electrostatic charge property. A switch should be installed on the van de Graaff, and the switching effect can be achieved with a script.

As shown in Figure below, the dangling fabric makes use of Unity’s Interactive Cloth components, which simulate a flexible grid of waving. Twelve small rigid colliders are added to the fabric every other time. These colliders are not directly nested in the Hierarchy, but they can use the Interwoven Cloth’s attach Colluders parameter. For all collision bodies in the fabric, there are two options: Two Way Interaction and Tearable. In this simulation, the Two Way Interaction mode has been chosen.

Van der Graff simulation
Van der Graff simulation

Click the left mouse button of the Van der Graff simulation, turn on the switch, and everything around the motor will gradually come closer together, as shown in the two figures below. (Unity3D game engine)

Van der Graff simulation
Van der Graff simulation

Earth’s magnetic field simulation:

The geomagnetic field, also recognized as the Earth’s magnetic field, is the magnetic field that extends from the Earth’s interior out into space, as illustrated in Figure below. At the Earth’s surface, its magnitude ranges from 25 to 65 microteslas (0.25 to 0.65 gauss). It is roughly the field of a magnetic dipole that is currently tilted at an angle of about 11 degrees with respect to the Earth’s rotational axis, as if a bar magnet were placed at that angle in the center of the Earth. The North geomagnetic pole, located in the northern hemisphere near Greenland, is actually the south pole of the Earth’s magnetic field, and the South geomagnetic pole is the north pole.

UV mapping textures
UV mapping textures

Uity3D to simulate the Earth’s magnetic field is used after learning the basic principles of the phenomenon. First, we add a sphere to represent the earth. The sphere is then given UV mapping textures. A texture map is a technique for adding details to a 3D object by mapping an image to one or more of the object’s faces. However, because the 3D model’s surface grows exponentially, creating a map for each face is impractical. As a result, the UV mapping used here paper has emerged. UV mapping is the process of transferring different blocks of a planar image to different faces of a 3D model. The horizontal direction is denoted by U, and the vertical direction is denoted by V.

UV mapping textures
UV mapping textures



Field lines can help us visualize electric and magnetic fields by tracking the curve that is always parallel to the field vector. The starting point of the curve is indicated by the position of the field line object. The field vector determines its entire direction. Field lines, which can be applied to electric or magnetic fields, change in real time as the field changes. The field line algorithm, which moves with the field, is self-configurable.

This algorithm is a differential equation that can be used in real time to simulate the field line. This algorithm is more complex and requires 11 parameters, such as the ones listed above, to be adjusted in order to achieve the desired effect of balancing speed and accuracy. If the scene and the starting point of the field line remain the same, use the calculate Only Once parameter to calculate once. The benefit of this is that you don’t waste time calculating the same line over and over.


In this paper, we simulate three electromagnetism experiments using the Unity3D game engine, demonstrating the feasibility of using game development techniques in education. The electromagnetism experiment simulations are implemented with high quality using the powerful functions provided by U3D. When compared to traditional experiments, its benefits, such as high development efficiency, low costs, and zero risk, are superior.

In addition to physics experiments, we can create virtual chemistry and biology experiments, which means the school only needs one laboratory to allow students to conduct all experiments without incurring huge costs for various experimental instruments.


Future Work:

This concept of explaining scientific terms using game engines must be implemented in all the educational sectors. In this way, we will produce brilliant minds with wide concepts who will play a great role in future science. It is also psychological proven that getting children involved into some concept using games is the best way to make them understand that concept. By doing so, we will also save a lot of cost for the sector that includes equipment of high amount of money.

also read here

how to design and manufacture electrostatic MEMS relay for high power application?

Leave a Reply

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