Before updating to Windows 10 you may need to return your Pro license. More information here

Are Animations faster than Scripting linear interpolation?

I am not sure if anyone knows or has done some benchmarking, but say I want to slide an object from position A to position B - is an animation more efficient, or is a script doing linear interpolation between the two points as efficient? Are there other, more efficient ways todo this?

In any answer, would the same apply for iOS targets?

Thanks H

P.s. If nobody knows I think I'll benchmark for iOS and post my results

more ▼

asked Dec 05, 2010 at 10:31 PM

avatar image

2k 83 72 131

I'd say that animation is faster as it is 1 line of code, and not multiple... But then again, you're calling a whole part of a file, so I don't know...

Dec 05, 2010 at 11:05 PM Justin Warner

Yeah I would agree with Justin, as animation would just be reading values to set the transform instead of calculating it.

Dec 06, 2010 at 12:17 AM reissgrant

I tried both in my program and the animation looked smoother to me. That said, I may have had a flawed script and would like if you benchmarked it for the iOS and posted the results.

Dec 06, 2010 at 01:23 AM Twayne

I asked a question like this before, and just got a bunch of annoying responses telling me to perform tests. I suggest you just post your test results and mark this as answered. Any information would be helpful; taking time to test for best practice on everything is not something some of us care to do; I'd rather be told what to do by someone I trust, so I can actually make games, instead. If I ever happened to come across contradictory results, oh well. I'll accept that possibility in exchange for the time I gain by not testing. :-P

Dec 06, 2010 at 01:57 AM Jessy

Yep, it's a tricky one. It feels like the animation should be faster as it's fired and the native code can handle it - but how heavy weight is the native code? More so than my C# compiled into native code?

Given that lots of things are working, testing this out might need to wait until I do some re-factoring to make some of the code more production grade, but I'll post the results as an answer for iOS, probably be tested on 3G S.

Dec 06, 2010 at 09:35 PM Bovine
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

So, I'm going to answer this in a slightly dubious way...

We have a tile based dungeon crawler (see link in my bio for a video, coroutines used in this vid) and we were using a Coroutine to move the player from tile to tile but I've now changed this to an animation. I made this change this for a couple of reasons:

  1. The coroutines were messy and our controller was quite messy as a result - now much cleaner

  2. The animations just run and our controller only has to setup the animation and wait for an animation event

  3. Using an animation makes it easy for us to add a little bobbing up and down as the player moves from tile to tile (not yet added)

  4. Coroutines are quite tough to save tbh...

it certainly feels faster, the animations are much more flexible and I would hope that the fact a script isn't being called every frame to martial the movement, that it's all event driven, means that it is faster.

I didn't benchmark this in a terribly scientific way, I had made the change mostly because of point 4 tbh and in doing it, the code became SO much cleaner to read, that it was worth it, provided that performance was acceptable.

We have a test LOD scene with 30 NPCs running around, sometimes all of them are in view, but either way, they are all always moving and it runs fine on 3G S and above. Animation time looking like being a typical 3MS, quite acceptable for this level of animation, including animating 7 skinned meshes as well.

Note that my answer is slightly dubious because I am saying it seems faster and it is certainly fast enough for our needs, but possibly as important is the ease of use of animations and how it helps to clean up and simplify the code.

more ▼

answered Jul 17, 2012 at 06:22 PM

avatar image

2k 83 72 131

Note that we limit the number of skinned NPCs to 5, 2 skinned meshes for the player arms. Our LOD system swaps the skinned mesh to a simple low-poly mesh fthat just bobs about. It's surprisingly effective and quite hard to spot that only 5 mobs are skinned and the rest are not.... anyway that's an aside.

Jul 17, 2012 at 06:22 PM Bovine
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Dec 05, 2010 at 10:31 PM

Seen: 2078 times

Last Updated: Jul 17, 2012 at 06:23 PM