Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Gravity Help

Is there any possible way to make a 3D physics object become unaffected by gravity?? Like if the physics body type was DYNAMIC for instance, is there any way for it to become unaffected by gravity??

Thanks in advance :)

Comments

  • dave1707dave1707 Mod
    Posts: 9,441

    @Creator27 Make it KINEMATIC. Have you looked thru any of the builtin reference. You’ll find a lot of info there.

  • Posts: 104

    @dave1707, I have tried using KINEMATIC bodies and linear velocity but didn’t work. Could you possibly show me an example??

    Thanks :)

  • dave1707dave1707 Mod
    edited September 3 Posts: 9,441

    Apparently you have to turn gravity off using scene.physics.gravity. But that affects all 3D objects.

    Or you can leave gravity on if you want to alter the direction it’s going under gravity.

    function setup()
        assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
        size=1
        scene = craft.scene()
    
        scene.physics.gravity=vec3(0,0,0)
    
        skyMaterial=scene.sky.material
        skyMaterial.sky=color(0, 62, 255, 255)
        skyMaterial.horizon=color(99, 255, 0, 255)
        scene.sun.rotation=quat.eulerAngles(20,45,-30)
        createObjects()
        v=scene.camera:add(OrbitViewer, vec3(0,0,0), 30, 0, 200)
    end
    
    function createObjects()
        sphere2=scene:entity()
        s2=sphere2:add(craft.rigidbody,DYNAMIC)
        s2.linearVelocity=vec3(1,1,5)
        sphere2.position=vec3(0,0,0)
        sphere2.model = craft.model.icosphere(size,2)
        sphere2.material = craft.material(asset.builtin.Materials.Specular)
        sphere2.material.diffuse=color(0,0,255)
    end
    
    function draw()
        update(DeltaTime)
        scene:draw()    
    end
    
    function update(dt)
        scene:update(dt)
    end
    
Sign In or Register to comment.