I’m interested to learn how game creators make “push” system, as if the players will be pushed forward. Is this using a BodyForce or what? I’m not quite sure.
I know for one thing that there is going to be custom animation made, but in terms of scripting, how would I be able to do this?
There are a few ways of making a ‘push’ system. You can use either CFrame/Position manipulation or use physics to do it.
Using CFrame/Position can lead to glitches like going through walls so it isnt recommended for people new to the subject. (Requires lookvectors, CFrame prediction, raycasting)
Using physics has many options.
– Adding Velocity to the character
– Making A Object Force (BodyForce or similar)
– Using constraints to drag the character
– Pushing player with a part (When a part is inside another part, physics cause it to be pushed out, has loads of problems, dont do it)
I recommend adding the velocity directly to the character, its much safer and easier to monitor and control.
Steps to make them get pushed towards where you want them:
Work out the direction the velocity needs to be.
if i am at 10,10,-50 and I want to get to -10,10,-40 I would apply negative X, nothing to the Y and Positive to the Z
Move the character by applying the a velocity until conditions are met (Can be multiple conditions encase they get stuck on a wall e.c.t). I would do max time of 1 sec or so and also check the position to see if the player goes within 2,2,2 of the target location
Don’t use YouTube videos, it will result in a poor copy of someone else’s work, if you are new to scripting, find your own way.
Many people copy others work from YouTube videos and the result is always a substandard product. This also means that the scripter learns very little from experimenting as the entire researching aspect of a project is removed when doing this. Researching via the APIs is essential otherwise you will get nowhere.
The only time you should use YouTube videos is to look for inspiration on how you can make your scripts surpass those before you.
Physics would be best as using CFrame or position can cause part clipping (Physics don’t like this when the manipulation ends, also leads to glitches like going thro walls if not done properly)
So using Physics is best in terms of easy set up and to reduce issues for those who arent advanced scripters.
You can directly set the velocity of a part to make it move
Here’s How:
Part.Velocity = Vector3.new(0,0,0)
Vector3 is used in position and velocity so it would be easy enough to calculate the vector
You can calculate vectors easy enough, here’s something visual you can use if you struggle to understand how all the axis work together to reach a location.