Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the instantaneous functions for physobj setAngleVelocity & setVelocity #1816

Closed
wants to merge 1 commit into from

Conversation

SubArrest
Copy link
Contributor

While browsing other addons code I noticed these physics object functions weren't in sf so I added them locally and tested them to see if they worked correctly (they do).

It wasn't immediately obvious to me why these wouldn't be added regarding abuse as it is relatively easy to apply very similar results in regards to abuse with regular addVelocity/addAngleVelocity inside a think hook or something.

I just found these added functions to be immediately useful for a few scripts I was working and I understand if it is prefered that the functions either need to be restricted more if added or not added in the first place (thought I would try my luck and see what your opinion is on having this added).

Cheers

@thegrb93
Copy link
Owner

How do they differ from setVelocity and setAngleVelocity?

@SubArrest
Copy link
Contributor Author

the regular setVelocity and setAngleVelocity don't update the velocities instantly to the set velocity, the added functions do

@thegrb93
Copy link
Owner

What do you mean instantly? You're saying getVelocity won't return what setVelocity sets?

@SubArrest
Copy link
Contributor Author

SubArrest commented Aug 16, 2024

Exactly, I'm not entirely sure of the details of why the regular set velocities don't do this but when testing the functions I had a setup similar to this:

local p = prop.create(...)
local ph = p:getPhysicsObject()
ph:wake()
timer.simple(1,function()
ph:setVelocityInstantaneous(vel)
end)

and using the regular set velocities did nothing while the instantaneous ones instantly made the prop move as its velocity was instantly set

@thegrb93
Copy link
Owner

thegrb93 commented Aug 16, 2024

] lua_run Entity(1):GetEyeTrace().Entity:GetPhysicsObject():SetVelocityInstantaneous(Vector(0,0,1000)) print(Entity(1):GetEyeTrace().Entity:GetPhysicsObject():GetVelocity())
> Entity(1):GetEyeTrace().Entity:GetPhysicsObject():SetVelocityInstantaneous(Vector(0,0,1000)) print(Entity(1):GetEyeTrace().Entity:GetPhysicsObject():GetVelocity())...
0.000000 0.000000 1000.000000
] lua_run Entity(1):GetEyeTrace().Entity:GetPhysicsObject():SetVelocity(Vector(0,0,1000)) print(Entity(1):GetEyeTrace().Entity:GetPhysicsObject():GetVelocity())
> Entity(1):GetEyeTrace().Entity:GetPhysicsObject():SetVelocity(Vector(0,0,1000)) print(Entity(1):GetEyeTrace().Entity:GetPhysicsObject():GetVelocity())...
0.000000 0.000000 1000.000000

Seems they both influence GetVelocity the same way. The only difference between the two I was able to find is that SetVelocityInstantaneous will not move the prop if it is asleep.

@SubArrest
Copy link
Contributor Author

Yeah after testing the regular functions in another server I just found this to be the case aswell, no need to add these then if the originals work fine

@SubArrest SubArrest closed this Aug 16, 2024
@SubArrest SubArrest deleted the instantaneous-functions branch August 16, 2024 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants