I'm working on proof of concept for some turn-based physics game. Imagine if you will the PoC; A large cube sits in space, the cube is a rigidbody. Turn time begins to countdown. When the large cube is clicked a small cube becomes x-ray visible. The large cube is no longer selectable, only the small cube. The small cube is dragged around until Turn time is 0. The large cube moves with force relative to the distance of the small cubes and towards its last position for the duration of play time. When play time ends the scene freezes for more input. Definitions Turn Time: A static scene time (in seconds) where the player may decide on the actions they wish to take by manipulating the interaction object (turnTime) Play Time: An active scene time (in seconds) where the player can not interact and observes the results of their choices (playTime) Large Cube: Player's character object (forceObject) Small Cube: The Player's interaction object (addForceObject) OPTION: The force can either presist through turns or it can be reset to 0,0,0. I'm not picky, but doing both would make fore fun game options. I'm not an experienced coder so I have tried to convey my idea is the best generic form of 'code like' I can conceive. Code (csharp): forceObject addForceObject playTime turnTime force addForce update if (turnTime <= 0) { //do (addForce +- force) for new force of object and run play time else { //get forceObject.location as local (0,0,0) then get addForceObject.location in forceObject's local space I think I have been doing things the hard way so I am going to ask for help before I waste time with mucked up code.
Alright well, I've had a couple beers and I won't pretend to understand the game concept but I'll give some hopefully helpful hints. 1) You can bring your physics objects to a halt by setting their rigidbody.velocity = vector3.zero 2) Find the force vector required to attract one object to another by subtracting their positions, normalizing the result, and then using a multiplier. 3) Use FixedUpdate (Not update) for Physics calculations 4) Multiply by Time.deltaTime where appropriate to account for inconsistent frame rate.