开发者

FlashDevelop: AS3 Tweening Stop on Steep Slope

开发者 https://www.devze.com 2023-04-10 15:58 出处:网络
I\'m using the caurina.transitions.Tweener; class with AS3 to tween a 3D object through my 3D environment (created with alternativa3D platform) from point A to point B. And everything works great, the

I'm using the caurina.transitions.Tweener; class with AS3 to tween a 3D object through my 3D environment (created with alternativa3D platform) from point A to point B. And everything works great, they move as intended from where they were to where I told them to go.

I was wondering if there was a way to make the object stop moving (or tweening) if the slope they were trying to walk over was too steep (like a giant hill or mountain in real life)?

This is basically the c开发者_如何学Pythonode I am using for this:

var playerDistance: Number = Vector3D.distance(
new Vector3D( _escapeeManager.activeEscapee.x,
_escapeeManager.activeEscapee.y,
_escapeeManager.activeEscapee.z ),
intersectData.point );

Tweener.addTween( _escapeeManager.activeEscapee, { x:intersectData.point.x, y:intersectData.point.y, time:(playerDistance/_escapeeManager.activeEscapee.speed), transition:"linear" } );

And if you'd like to see an example in the game I'm developing, it can be found here: http://redmenmusic.ca/godsend.html

Thanks for your help guys!


It seems a bit odd to use Tweener for anything other than superficial animations - you probably need to implement a more complex system to handle object movement, collision detection, slopes etc.


The caurina.transitions.Tweener has some properties that could come by handy for your problem. I'am not saying it's the Tweener is the best way, bit it will get you where you want I guess :).

The official Tweener documentation website can be found here: http://hosted.zeh.com.br/tweener/docs/en-us/. The section 'Tweening parameters' would be a interesting read for you.

So for your problem, I would suggest to approach it this way: There is a onUpdate event which is executed on every update of the Tweener. On every update you could check if the slope is to steep or not. Example: Tweener.addTween(myMovieClip, { x:100, time:1, onUpdate:function() { /* check here if the slode is to steep - if it is you can remove the Tweener on the object and proceed with an other function */ }});

I hope it's clear :) Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消