also if you need the model
uploads_files_624509_CubeRig.fbx (244.7 KB)
Will this work with not allowing the SmartBone to collide/go through the player?
I got bone attributes working, also supports updating attributes at runtime:
Let me know if there are any issues with it.
Well, thanks for nothing anyways, would be cool if you couldâve shared just a bit of it.
Nobody is obligated to share resources unless youâve paid them or have a contractual agreement.
Anyways, what it looks like theyâre doing is if the character is moving backwards with relative to the character facing forwards, it âdisablesâ or begins to stop the smartbone from acting.
And if its for any other direction of movement/velocity, it is enabled. In other words, the more closer you are to âwalking back while facing forwardsâ, the more closer to 0 it is (in other words disabled). (Standing still makes it 0 as well)
A method that can be indeed referred to faking collision (because there is no collision detection being calculated).
You guys could add some basic capsule collision testing as the math behind it is very simple.
I tried implementing this with a cape but whenever I walk backward the cape flies into my character, any known solutions to something like this?
You can write some extra code that limits the local positioning along a certain axis
Did you enable SmartBone in the tag editor?
do you know how you would do that
Before each position update on the bone you simply test itâs intersection with all the defined capsules
Using this math:
-- this solves the closest point on a line to a point. we can use this to solve capusle intersections
local function solve(p0, d0, p1, len)
local v = p1 - p0
local k = v:Dot(d0)
k = math.clamp(k, -len, len)
return p0 + d0 * k
end
-- next we define some parameters about our bone and capsules to test
-- capsules we test against
local capsules = {
{
LocalPosition = Vector3.new(),
Adornee = workspace.Baseplate,
Radius = 3,
Length = 3,
Direction = Vector3.new(0, 1, 0),
}
}
-- bones we test against
local bones = {
{
WorldPosition = Vector3.new(0, 1, 0),
Radius = 0.15,
}
}
for _, bone in bones do
for _, capsule in capsules do
-- this is where the magic happens
local w0 = capsule.Adornee.Position + capsule.LocalPosition
local d0 = capsule.Direction
local l = capsule.Length
local w1 = bone.WorldPosition
local p0 = solve(w0, d0, w1, l)
local safe_distance = capsule.Radius + bone.Radius
local m0 = (p0 - w1).Magnitude
if m0 >= safe_distance then
-- We are safely outside of the capsule!
continue
end
local d1 = (w1 - p0).Unit -- Get the direction to the bone
local p1 = p0 + d1 * safe_distance
bone.WorldPosition = p1
end
end
This is just demo code so you would have to change it quite a bit to get it working with smart bone but the idea is there, I would also recommend writing a plugin or a script to automate the creation of the capsule data.
This could also be expanded to work with cubes and spheres but I wont get into that as it complicates the math quite a bit.
If there are any issues with the math please tell me.
Demo: (Each solve takes roughly 0.003ms)
Is there any way to make it work as morph without need use starter character?
if u could make this collide with objects, players would it be possible to create interactive grass?
You can already do this without smartbone and have it run faster.
I already have a solution for sphere and capsule collision, however box collision has been a real pain and Itâs the main thing preventing this update currently.
ok can you tell me how please?
Has the upcoming workspace:Blockcast() method helped? Itâs working for me in studio but crashes anytime I try to actually play it without studio.
Amazing work! however any plans for adding support for multiple wind directions at the same time? Perhaps even support for some sort of point in world space that casts a force in all directions?
I can share the solution I came up with if youâd like however it only works with swept collisions as if the point is inside of the box it falls apart (there are some hacky ways to have it kind of work but nothing perfect with my solution)