I create magnet, but when magneting , all objects fase at magnet position. need only addrelative force to position of magnet with no keep rotation as direction of force.
Now this code :
void Update(){
if (inside) {
transform.LookAt (magnet.transform.position);
rb.AddRelativeForce(Vector3.forward * magnetingforce);
}
}
Because you are using LookAt, you are turning to face the magnet. Instead, you want the direction vector from the object to the magnet. You can get this by using the following code:
Vector3 direction;
direction = (magnet.transform.position - transform.position).normalized;
rb.AddRelativeForce(direction * magnetingforce);
That should work for you.
In this article, we will be discussing how to create magnets. Magnets are created by surrounding material with a magnetic field. The most common way to create a magnet is by using an electromagnet. This is done by passing an electric current through a coil of wire that is wrapped around the material. The resulting magnetic field causes the material to become a magnet
What Materials Can Be Used To Make Magnets?
[200684-magnet-gc71a2d35c-640.png|200684]
The most common materials used to create magnets are permanent magnets, ferromagnetic metals, and diamagnetic metals. In this article, we will be discussing how to create magnets using ferromagnetic and diamagnetic metals. Ferromagnetic Metal Magnets: A ferromagnetic material is a material that has the tendency to become magnetized when it is exposed to a magnetic field.
In other words, when a ferromagnetic material is exposed to a strong magnetic field it becomes magnetized and remains so. Some examples of ferromagnetic materials are nickel and iron. Nickel Iron Also known as ferrite magnets, ferromagnetic metals can be used to make permanent magnets.