Getting in the habit of doing a dev blog after any amount of dev work.

Last night I added a very basic planet Mercury to a space game I've been working on. Got up to a skinned sphere that moves from it's start point to a fixed location (so exciting!)

Beautiful skin made in GIMP by yours truly:

And here it is on a sphere:

And it wouldn't be a dev blog without a code snippet. This one moves the planet to a pre-set spot, so that it moves into the play area after it spawns.

if(!transform.position.Equals(destination)){
Vector3 toDest = destination - transform.position;
toDest = Vector3.Normalize(toDest) * Time.deltaTime * speed;
transform.Translate(toDest);
}

With that checking for position.Equals(destination) I was expecting more of a wobble around the destination, but it ended up really smooth.

Post Comment

Hello World!