I feel like we have 2 STATIC rigidbodies and no KINEMATICs. It should be noted that the only reason I turned to using KINEMATICs was because there also is no gravityScale for DYNAMIC rigidbodies.
I don’t think you can remove gravity from an entity can you? I don’t recall seeing that as something that could be removed. If I removed physics then that would also halt physics based movementalong the x and z axes.
Its not just movement but detection would become an issue as well. Without physics the object would not be detected. Since all craft detection methods use physics.
Long and shirt of it. We could really use a craft version of gravityScale so we could set it to 0.
@Rdo I don’t think gravity can be turned off for some objects and not others. It’s probably an all or nothing setting. As for KINEMATIC, it does do what it’s supposed to do when it works correctly. @Simeon KINEMATIC doesn’t seem to work right the majority of times. Using the code below, I saw the sphere do 4 different things when I would keep restarting the program.
The sphere bounced off the cube correctly about 1 out of 20 restarts.
The sphere slowly sank into the cube the majority of restarts and would have an odd y value that I display at the top of the screen.
The sphere bounced off the cube at an odd angle.
The sphere sank about half it’s diameter into the cube and totally stopped.
function setup()
assert(craft, "Please include Craft as a dependency")
assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
fill(255)
scene = craft.scene()
v=scene.camera:add(OrbitViewer, vec3(0,0,0), 100, 0, 200)
v.rx=20
createRect()
createSphere()
end
function draw()
update(DeltaTime)
scene:draw()
text("Drag your finger on the screen to rotate the cube",WIDTH/2,HEIGHT-100)
text(sphere1.position.y,WIDTH/2,HEIGHT-50)
end
function update(dt)
scene:update(dt)
end
function createRect()
c1=scene:entity()
w=c1:add(craft.rigidbody,KINEMATIC)
--w=c1:add(craft.rigidbody,STATIC)
w.restitution=1
c1.position=vec3(0,0,0)
c1.model = craft.model.cube(vec3(10,10,10))
c1:add(craft.shape.model,c1.model)
c1.material = craft.material("Materials:Standard")
c1.material.map = readImage("Blocks:Trunk White Top")
end
function createSphere()
sphere1=scene:entity()
s1=sphere1:add(craft.rigidbody,DYNAMIC)
s1.restitution=1
sphere1.position=vec3(0,10,0)
sphere1.model = craft.model.icosphere(1,1)
sphere1:add(craft.shape.sphere,1)
sphere1.material = craft.material("Materials:Standard")
sphere1.material.diffuse=color(255,0,0)
end
@Rdo Now that I can get the KINEMATIC to work every time adding my change above, here’s an example that shows that KINEMATIC does what it’s supposed to do. Slide the parameters to move to cube around.
function setup()
parameter.integer("xx",-5,5,0)
parameter.integer("yy",-5,5,0)
parameter.integer("zz",-5,5,0)
assert(craft, "Please include Craft as a dependency")
assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
fill(255)
scene = craft.scene()
v=scene.camera:add(OrbitViewer, vec3(0,0,0), 100, 0, 200)
v.rx=20
v.ry=20
createRect()
createSphere()
end
function draw()
update(DeltaTime)
scene:draw()
text("Drag your finger on the screen to rotate the cube",WIDTH/2,HEIGHT-100)
text(sphere1.position.y,WIDTH/2,HEIGHT-50)
end
function update(dt)
c1.position=vec3(xx,yy,zz)
scene:update(dt)
end
function createRect()
c1=scene:entity()
w=c1:add(craft.rigidbody,KINEMATIC)
w.restitution=1
c1.position=vec3(0,0,0)
c1.model = craft.model.cube(vec3(10,10,10))
c1:add(craft.shape.model,c1.model)
c1.material = craft.material("Materials:Standard")
c1.material.map = readImage("Blocks:Trunk White Top")
end
function createSphere()
sphere1=scene:entity()
s1=sphere1:add(craft.rigidbody,DYNAMIC)
s1.restitution=1
sphere1.position=vec3(0,20,0)
sphere1.model = craft.model.icosphere(1,1)
sphere1:add(craft.shape.sphere,1)
sphere1.material = craft.material("Materials:Standard")
sphere1.material.diffuse=color(255,0,0)
end