The main reason is that it can easily mess up your scene if not used with caution. You may now be thinking of many great scenarios when you would use ExecuteInEditMode annotation, but be careful! If you research a little, you will find out that it is often considered evil and unpredictable. Now it’s time for the real thing! Please note that everything is done on the Scene view without going into the Play mode! I’ve added labels to each object to help you tell one from another. Each body object will follow the body/head on the front, so Body 3 ( 1) follows Body 2 ( 2) etc.Īnd here’s how our scene looks like in the Scene view. Now let’s set up the scene by creating something like a snake. It’s no different than usual game script, but pleace notice the annotation before class definition. What this code actually does? It makes the current object follow another. Transform.position = follow.position + followToCurrent Var followToCurrent = (transform.position - follow.position).normalized įollowToCurrent.Scale(new Vector3(maxDistance, maxDistance, maxDistance)) change this object position only if the distance is greater than maxDistanceįloat actualDistance = Vector3.Distance(transform.position, follow.position) This scripts follows the target object on the straight line ![]() As a result all single camera parameters will be locked and can be changed only by using the management script.Īnd a lot more… I am sure that you will find a lot more cases when you would use ExecuteInEditMode annotation, but for now let’s see a code example showing how to use it. Instead of changing those manually (yes, you can select all of them, but there’s no guarantee that someone else will do the same) you can make your management script adjust all values using one master value. Let’s say that your scene has 5 cameras, but all these cameras should have the same FOV parameters. ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |