Wanting to find a solution to rotate a part in circular motion around an object but be able to push players in the game.
I’ve seen several posts but can’t find something directly as to what I am after.
I have done a few other things in relation to rotating parts with CFrame(not an expert.) and have found that it doesn’t affect the player so wanted to know if using attachments would be a better option.
Essentially, I am trying to make a jump rope spin in circular motion around a point as above but would like push the player if they touch the rope…
I understand you can use .Touched event to detect if the rope hit a player and BodyVelocity to push the player but thought that attachments might be better for it.
It’s not deprecated, and those methods are spatial queries, they are not the same.
It is dependent on physics, and from my experience it works just fine.
The engine handles the collision detection, and is off-loaded to the network owners of the assemblies, a spatial query would probably be far slower, especially if you have to check every frame.
Additionally, as Touched events are sent from the network owner of that part, it’s better in most cases for user experience, imagine dodging a kill brick from your view but you still die anyways.
Simplest approach would be to raycast downwards from the HRP every frame, if rope is in contact then calculate pushing direction and use HRP:ApplyImpulse. Rope should ideally be anchored and rotated by the server (physical simulation is not necessary) and the pushing will be handled by client as the client owns the character model. This will also not cause desync due to ping.
Could you please provide actual proof that .Touched events are slower than spatial querying every frame?
Think about it logically, would constantly performing spatial queries be faster than listening to an event for something the physics engine already does?
For OP’s case, Touched events should work just fine, as long as the rope is owned by the server, clients cannot trigger touched events for other clients.
Use BVHs for that, which are faster and more reliable than Roblox .Touched.
You can make one yourself or you can get a nice module which I use too called: SimpleZone which uses zones and BVHs to check if a player or an object touches them.
For the spin motion you can use bezier curves.
For the pushing you can use zones as I mentioned earlier and make a simple knockback when the player touches the part.
By attachments I meant using something like a hingeconstraint, or motor… please forgive my ignorance on the subject as I am not too experienced with them, I just thought that one of the few constraints ROBLOX has implemented might be used for this.
Would using beams be ideal for my use case? A little extra detail as I forgot to add.
In the game I am creating, the rope is not to be used by 2 different players, it’s just held up by a dummy and constantly spins. Players in game are supposed to jump over the rope to prevent being hit by it if that makes sense.
I did try using CFrame for this task, but found that I likely need to study more on the topic in regards to trig etc… but also the fact that players arent impacted by the rotation of a part even if it’s thrown at them.
This sounds like a good approach to throwing the player off balance. I will have to get a bit more in-depth with my CFrame knowledge for the rotation part as it involves a bit of trig to my knowledge, and will definitely try this and let you know.
Would bezier curves work in my use case? I mean, the rope is going to be spinning around a constant circumference. Never really used bezier curves but from what I can see they are designed to create a curve from two points. I’ve attached a GIF below that may help visualise this.
(If you can visualize this in a circular motion rather than 90* degree angle)
Just use a mesh with precise convex decomposition or multiple parts using .Touched events on the client so there isn’t any delay when they touch the rope. Use hinge constraints to rotate the rope so everything’s physics based.
Beams are excellent if you want to keep performance first. They are pretty good and would provide a plausible rope effect. For more realism, you can use a part rope and use Workspace:GetPartBoundsInBox(RopeSegement.CFrame,RopeSegment.Size) to check for collisions. Do use OverlapParams to filter out unnecessary things like the rope segements themselves and other stuff.
You dont need bezier curves, you just need a simple rotation loop.
local radius = 10
local angle = 0
local speed = 100
game:GetService("RunService").PreSimulation:Connect(function(dt))
angle += speed * dt
local ropeCF = CFrame.new(centralPos) * CFrame.Angles(0, 0, math.rad(angle))
ropeCF *= CFrame.new(radius, 0, 0)
end
Something along this lines will be enough. I recommend using this with a twisted rope model unless you want to simulate it physically, then you’d have to use editablemesh/mesh deformation of some sort.
Yeah you can use them but I think I misunderstood what you said, as in this case they are not optimal so instead of bezier curves you could rotate the cframe alongside a center point on a specified axis, just like @MasterOfCFrames said.