Help

I’m trying to bring a simple sprite into my 3d scene and I either get an error saying it is null, or if I call up it as a scene entity, it now doesn’t even show up.

If someone can help me out, it would be awesome.

Here’s my current coding, where I get no errors, but the sprite doesn’t show up.

function setup()
	-- Create the scene
	scene = craft.scene()
    createGround(-.8)
  -- Move the main camera
    scene.camera.z = -12
    
    
    mySprite = scene:entity()
    
    mySprite = sprite("Documents:TEXT BUBBLE",WIDTH/2,HEIGHT/2,1024)
  -- Adjust the scene lighting
  scene.sun.rotation = quat.eulerAngles(30,0,0)
  scene.ambientColor = color(10, 10, 10, 255)

  -- Turn on fog and set distances and color
  scene.fogEnabled = true
  scene.fogNear = 2
  scene.fogFar = 18
  scene.fogColor = color(127, 127, 127, 117)

  -- Get the sky material and change the sky and horizon colors
  skyMaterial=scene.sky.material  
  skyMaterial.sky = color(85, 128, 217, 255)
  skyMaterial.horizon = color(194, 195, 220, 255)
    
end

function update(dt)
	-- Update the scene (including physics, voxels and other systems)
    scene:update(dt)
    
end

function draw()
    
	update(DeltaTime)

	-- Draw the scene (must be done within the draw function)
	scene:draw()

end

When I add
mySprite.x = 1

It comes up with a new error

Hi @Kurall_Creator

This is because the sprite() function does not return any values. It draws a sprite immediately on top of the current background (and only in that frame). If you want to put a sprite in the scene you’ll have to set the model and material for your mySprite entity and set the material to use the image you want. If you just want to draw on top of the scene then put your sprite call after scene:draw() and it will appear in front of everything else.

Thanks for replying John.

I came to that conclusion as well, and I found an ingenious way to ensure the position of the sprites could change when you touched the screen - which was what I was looking for - creating a touch sensitive cutscene.