Animation & Apps using ONLY scripting

Hi everyone! My first post on here. I’m an indie iOS Developer. I’ve worked with Xcode, Interface builder, cocos2d, sprite kit, etc…

Since playing with Unity (C# scripting) for a few days, I’ve had a little bit of trouble trying to figure out how to do some things that I would do on iOS. Maybe someone could help me out?

  1. I’m trying to animate GameObjects using scripting ONLY, and while moving something over time using the update() method works fine, I was wondering if there was a way to just simply tell an object to transform to a certain position/rotation/scale over a certain time period? Like I have some 3D Text, and it’s off the screen, and when the screen is tapped, then the 3D text moves from whereever it is to (0,0,0) in 1.2 seconds?

Everytime I look on the internet, there seems to be talk about how to create animations using the Unity interface with keyframes and such, which is fine, but I want to do things dynamically, so I’d need to script everything in this case.

  1. Next, my update() method seems messed up. It’s jittery. I don’t know why. I just translate to move in the x-position 0.1 every update method: new Vector3(transform.position.x + 0.1f, 0, 0).

After searching the internet for a solution, it seems like a lot of people have had this issue. Has there ever been a real resolution to this? It’s a simple scene where the camera is panning. There are about 10 primitive objects in the scene with about 4 materials is all.

  1. Does anyone have any tips/resources on creating multiplatform (most all mobile smart devices: iPhone, iPad, Android, Windows Phone, Blackberry) apps using JUST scripting? I prefer scripting when I can because at least when it came to iPhone/iPad, I can just scale things based on the screen (not a perfect solution, but I’m an indie developer striving for results, not perfection). Scaling based on screen size seems to be the easiest way to target multiple platforms when it comes to what the users see. And writing the code once and just ignoring as much as possible the Unity Interface is preferable (at least for now).

The easiest way to move objects around over time using code is to…let someone else do it! There are free tools out there that are in common use. Two such packages are iTween and HOTween (which will soon be called DOTween in v2, apparently).

I’ve used both, and they both work well and are easy to use, especially if you just want results. Both provide nice things like callbacks and easing functions. Both are actively maintained, and do things that I didn’t want to write myself. Pretty sweet.

As for your translation issue, you really should be using a rate of movement over time rather than moving by a fixed distance every frame.

Something like:

float rate = 2.0f;
transform.Translate(rate * Time.deltaTime, 0.0f, 0.0f);

Since you’re dealing with a 3D text object, the rate is in world-units per second. The Unity learn section is great if you haven’t found it yet.

http://unity3d.com/learn/tutorials/modules/beginner/scripting/translate-and-rotate