manumqln Posted February 2, 2021 Posted February 2, 2021 I want multiple elements (images/divs) to move around the HTML page in random motion bouncing of each other and the edges of the screen. The example I have given is in GSAP2.0. Can anyone help how to do this in GSAP 3? See the Pen vYyOmQw by manumqln (@manumqln) on CodePen.
mikel Posted February 2, 2021 Posted February 2, 2021 Hey @manumqln, Welcome to the GreenSock Forum. Here is such a concept. Maybe it helps. See the Pen abBOwbR?editors=1010 by mikeK (@mikeK) on CodePen. Happy tweening ... Mikel 2
ZachSaucier Posted February 2, 2021 Posted February 2, 2021 Hey manumqln. Upgrading is easy if you follow the migration guide:
ZachSaucier Posted February 2, 2021 Posted February 2, 2021 @mikel You're using GSAP's random functionality and a hand-written random function in that demo. Why not just use GSAP's random functionality? [prop]: gsap.utils.random(min, max) 1
mikel Posted February 2, 2021 Posted February 2, 2021 Hey ZACH, Good point. I was too quick to migrate ... Thanks ... Mikel
manumqln Posted February 2, 2021 Author Posted February 2, 2021 @mikel this is very helpful. But I would like to bounce the items when they meet each other rather than overlapping.
ZachSaucier Posted February 2, 2021 Posted February 2, 2021 32 minutes ago, manumqln said: I would like to bounce the items when they meet each other rather than overlapping. That's quite different than what you currently have You'll have to implement direction tracking (at the least the angle it's going at), hit detection for all of the boxes, and then each time they "hit" you will need to create a new animation that goes in a new direction based on which edge hit and the previous angle it was moving at. 1
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