I am trying to develop a program that accomplishes two tasks.
The first task is to create a static body in craft and a dynamic body which interact such that the first body is much like a floor and upholds the second body which has gravity (a ball falling to the ground).
The second objective is to create a class and use the entity:add() method with that custom class and in a very simple way understand what that does.
As of now I have a dynamic icosphere which falls through a “floor” and I don’t know how to setup a custom class for the add method.
Any help appreciated.
@bjhobson12 Here’s something I already had.
assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
scene = craft.scene()
skyMaterial.sky=color(0, 62, 255, 255)
skyMaterial.horizon=color(99, 255, 0, 255)
v=scene.camera:add(OrbitViewer, vec3(0,0,0), 100, 0, 200)
text("Drag your finger on the screen to rotate the cube",WIDTH/2,HEIGHT-100)
c1.model = craft.model.cube(vec3(25,1,25))
c1.material = craft.material("Materials:Standard")
c1.material.map = readImage("Blocks:Trunk White Top")
sphere1.model = craft.model.icosphere(1,5)
sphere1.material = craft.material("Materials:Specular")
You are awesome—seriously
Just a side node, you don’t have to add the model (this doesn’t do anything), just assigning it will work.
@John Are you talking about the 2 lines I show below. If I comment them out, everything looks OK but the physics part doesn’t work. The ball passes through the floor. I tried commenting other lines, but then either the object doesn’t show or I get an error.
Ah, never mind I missed the
craft.shape. part, which makes sense. You were right.