CryOfGaming Posted July 12, 2021 Share Posted July 12, 2021 Hello, i have a project running in html5 canvas. Since i cannot tell anything about the project itself, i try to make it easy to understand with other stuff. Lets call the first object A and the second object B Object A gets moved by the users mouse (i handled that without TweenLite) and object B should stay to the same relative position as object A. Object A can rotate, when it rotates object B rotates around object A to get the same relative position. This all works perfectly. This code gets called around 150 times a second to try bring object B to the target position at A. TweenLite.to(this, 0.5, {x: this.targetX, y: this.targetY, }) (decreasing duration in this code will look bad, so when i make it on 0.1 its lags not a lot behind but it looks bad) Now the problem i have is that object B lags behind as long object A is moving. When object A stops, object B has no problem to reach the target position but since object A is constantly moving, object B wont reach object A. I tried to make some picutres to make it understand it better: Here you see object not moving - everything is good. Object B is in correct position Now object A rotatet a bit around, object B followed. Also looks good ( think it also lags a bit behind, but since the rotation is not fast, its not noticable) But now object A starts speeding up to a higher constant speed - object B trys to follow with the code that gets called 150 times per second, but it looks like that: I hope i somehow made it understandable 😄 So basically everything is working, rotation is looking good (nvm that small lag cause of the low rotation speed) but as soon it speeds up, object B got a distance which wont go any closer. Thank you for any help! Link to comment Share on other sites More sharing options...
OSUblake Posted July 13, 2021 Share Posted July 13, 2021 Hi CryOfGaming! We're happy to answer any GSAP-specific questions, but we don't have the resources to provide free general consulting. This sounds more like a logic problem. For mouse movement, I usually use a lerp-like animation. See the Pen WNNNBpo by GreenSock (@GreenSock) on CodePen Of course anyone is welcome to assist with that if they want to, but it's highly unlikely that you will get any type of response without a minimal demo. I also noticed that you are using a deprecated syntax. Check out the migration guide. 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now