SpotLight problem.

Hello everyone.
I want to create a spotlight attach to my model (self.boy) like the picture below.

I can attach it to model by this code.

self.boy.attachNewNode( self.spotlight.upcastToLensNode() )

But I don’t know how to set up the direction of the light. (like the picture above.)
(I had read the code in “” but it wasn’t set the direction I think)
Help me ,please. :cry:

“attachNewNode” returns a NodePath. I think you can change the direction of the spotlight by changing the orientation of this NodePath.

The code below is from the Panda3D manual, and it sets the direction of the spotlight this way, by setting the orientation of slnp via lookAt method. But I guess setHpr or other ways to change the orientation work too.

Oh, and I think up-casting is no longer required.


slight = Spotlight('slight') 
slight.setColor(VBase4(1, 1, 1, 1)) 
lens = PerspectiveLens() 
slnp = render.attachNewNode(slight) # in your case self.boy.attach...
slnp.setPos(10, 20, 0) 

Oh Thank you!! :astonished:
It 's work!!