Suggestion Needed to Move Several Objects ( Logic only)
HI
I am in process of creating a mobile game where I need to move many object at the same time.
Background:
I touch one OBJECT_1 and Drag it to a position(vector2 position)
ON_FINGER_UP , Object start moving towards the position(vector2 position)
While OBJECT_1 is still moving I moved OBJECT_2, and it started moving as well.
I have several object which a user can move with finger (players). Along with some automated moving objects on a certain path (enemies)
Motion is not Physics based i am using following :
transform.position = Vector2.Lerp(transform.position, distPoint, Time.deltaTime * speed);
To make objects move I have 2 approaches
Approach 1
Create a MonoBehaviour Script (with my motion functions)
Attach the Script to all Moving Objects That I want to move,
ON_FINGER_UP, Send message to Object to start moving ClickedObject.SendMessage("moveStart",V2coordinates, SendMessageOptions.DontRequireReceiver)
update() will wait for moveStart Flag , and once moveStart Flag received, then
update() I keep moving my object.
Once Object reached destination, moveStart Flag is set false,
Approach 2
Create a MotionManager Empty Game Object
Attach MotionManager Script (with my motion functions)
ON_FINGER_UP, GetComponent< MotionManager >() and call a function void MoveObject(GameObject Object2Move, List MotionPath, float speed)
Function MoveObject can move the objects using 2 approached
a. Start a new Co-routine ( StartCoroutine())
b. Use the update() function and move the object ( this option seems no good, as this will be moving objects one by one and I have 15+ objects moving, so first object will have to wait for all objects to move )
I need your advice what approach should I adopt for a better performance in terms of mobile resources utilization,
Your answer
Follow this Question
Related Questions
Multi-core PCs and performance. 0 Answers
Multiple small update calls vs one large update call? 1 Answer
Performance Issue with Coroutines 2 Answers
Unity performance questions 1 Answer