3
votes

On my scene I've got an ambient light and an omni light, none of which casts a shadow. My game works a bit like temple run, with a player constantly advancing along the z-axis. I want to add a light that shines form left to right, parallel to the z-axis, casting a shadow on every single node from the left to the right, a bit like in this game:

enter image description here

I tried using a SCNLight of type "Spot", but then the light comes from a particular point in space. I tried the directional lighting, but all I can manage to get is a light that shines from back to forward and creates very long shadows. It would be great if I could change the shadow length and the orientation of the light. I tried doing this:

spotLight.type = SCNLightTypeDirectional
    spotLight.castsShadow = true
    spotLight.shadowMode = SCNShadowMode.Deferred
    spotlightNode.light = spotLight
    spotlightNode.orientation = SCNQuaternion(0.0, 0.0, 1.0, 0.0)
    rootNode.addChildNode(spotlightNode)
1
did you find a solution?Crashalot
@Crashalot Nope, never found a solutionAlessandro
so what did you do regarding the lighting?Crashalot

1 Answers

2
votes

Change direction of your spotlight by Euler Angles

spotlightNode.eulerAngles = SCNVector3(-Float(M_PI_4), -Float(M_PI_2), 0)