How to punch a object to have it go a set distance before falling

Hello everyone,

This is a 2 part question, and i apologize if these have already been answered, i probably didnt see them in my search for a resolution.

What im looking to create is the ability to punch a object, in this case a punching bag, and based on a variable like strength i would like the punching bag to go a set distance before gravity takes hold and it bounces to a stop, which would be the distance in studs they gained. I searched around, and the only thing that could be of use it to use ApplyImpulse. Thoughts?

The second question is related to the first, how would i show this distance traveled on the players gui? Like a player travel progress bar with the players face as the indicator.

2 Likes

Hello Krimzin78, I have seen many games follow the criteria you are following where an object is launched and lands at a position; these are most likely using TweenService. You can use TweenService to give a basic value which will be how far they will always punch, then add extras like pet force, boosters, etc. Add that on top of the stud count, then have the Punching Bag tween to that position. TweenService has different TweeningStyles, which fit the rubric you listed, “set distance before gravity takes hold”. For the second question, the correct format would be (OriginalPosition - NewPosition).Magnitude (IIRC). Let me know if you have any further question or need further analysis.

~ Sincerely Ihaveash0rtname
“Happy Scripting!”

How would something like that look? I understand the tween, but how would gravity, and additional force work. Would i apply gravity. And tween again for the additional? Sorry, this subject stumps me for some reason.
I thought magnitude would play a part, but how would you subject that to gui x and y?

You don’t actually apply anything with gravity, EasingStyle or EasingDirection for the second question with converting it onto a GUI you can look up on the Dev-Forum many people have made example of turning Distance into a distance completed frame.

~ Sincerely Ihaveash0rtname
“Happy Scripting!”

Thanks for the advice, not sure how to use it. Guess ill have to do some more research. My tween skills need some work.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.