Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Does a PhysicsStepped event exist? [closed]

Asked by
Dfzoz 489 Moderation Voter
4 years ago

I was creating a golf game some time ago but I stopped working on it because I couldn't create a wind factor that is precise. I would like to know if there is an event that fires along with every physics update so I can maybe add it.

Closed as Not Constructive by JesseSong

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
1
Answered by
SteamG00B 1633 Moderation Voter
4 years ago

Fifkee is wrong, you never want to do any physics related updates with RenderStepped, that should be reserved for camera manipulation only! Even in the link he provided, it shows that the physics simulations happen after the render occurs. If you do decide to use RenderStepped for everything, your game will have low fps even on high end computers. So what you should do instead is use the Heartbeat:

game:GetService("RunService").Heartbeat:Connect(function()

end)
Ad
Log in to vote
1
Answered by
Fifkee 2017 Community Moderator Moderation Voter
4 years ago
Edited 4 years ago

Physics updates occur every frame. Knowing this, you can utilize the RenderStepped signal like so:

game:GetService("RunService").RenderStepped:Connect(function()

end);

You can see what happens in a frame in this image provided by the Roblox Developer Forum: https://devforum.roblox.com/t/how-does-runservice-work/619565/2