Beginner tutorial : Ray sensor with material type

Hi,

I’m new to Blender and it looks quite interesting. I’m working on a simple tutorial to build a small game. This is the procedure :
I add a plane and work on it to obtain the game board. I’m going to material and add a color. I select a face and add another material with green diffuse (naming it “arrival”) then I click on assign. This is the result in edit mode :


In object mode, I add a blue sphere at game start point. Physics is dynamic with anisotropic friction to 0.
Selecting the gameboard, in logic editor, I use arrow key and motion on the plane and test game. Applying rotations with the arrow keyboard move the sphere because of the slope. Good until there :yes:.

Now, when the player hit the green material, the tutorial say we’re going to change the scene “Game” for the “Win” scene. I prepare the scenes and coming back in the logic editor.
On the sphere, I add a ray sensor with material type and select “arrival”. I choose -Z axis with 0.5 range (I assume it’s equal to 1/2 blender current unity). In actuator, I add a type scene with add overlay scene type and select “Win”. I add another one with suspend scene and select “Game”. This is the logic :



When lauching the game and reaching the material, nothing happens.
I try the pulse mode => nothing
I try the X-Ray mode => nothing (no logic because the material isn’t hide behind an object :spin:).

I think, the problem can be in relation with the sphere axis (I think they re rotating, then z is relative to the rotation of the sphere ?)

Any idea, advice or even better, a solution ?

Thx for help.

Physics objects usually have some margin.

I think you should make your ray a bit longer than 0.5 as your sphere might prevent the last tiny bit to recognize the ground.

Yes, the ray measures in object space (it turns with the object).

I think a Collision sensor can help you there.

You can place empty under sphere:


cont = logic.getCurrentController()
own = cont.owner
empty = getTheSceneObjectInTheWayYouPrepare()

empty.worldPosition.xy = own.worldPosition.xy
empty.worldPosition.z = own.worldPosition.z - 2.0

And than cast a ray from own to empty using rayCast() (http://www.tutorialsforblender3d.com/GameModule/ClassKX_GameObject_21.html)


When you have done ray casting, you can use that ray. For example,

ray = own.rayCast( empty, own, 0.0, “arrival”, 0, 1, 0)
if ray:
cont.activate(cont.actuators[“Scene”])
cont.activate(cont.actuators[“Scene.001”])


In this specific case you need a seperate object with property "arrival" to do this...

Ok I learn how to use collision thx a lot :slight_smile:
But nothing change :


Then I try a longer ray, no more results :


I surely miss an obvious thing somewhere. This is my material :


Maybe something in the sphere object ?

I’m just a beginner then I got a long way to go before scripting (even if I try once and it works :confused:. This tutorial comes from a book on Blender and it’the first project. It should work without Python.
This is the second screen on material parameters
:

And then the object sphere :



I hope it gives you some keys.

Try to use true level triggering. In latest versions it is more oftenly required thing.

I’m just a beginner then I got a long way to go before scripting (even if I try once and it works :confused:. This tutorial comes from a book on Blender and it’the first project. It should work without Python.
This is the second screen on material parameters[ATTACH=CONFIG]396827[/ATTACH] :

And then the object sphere :
[ATTACH=CONFIG]396828[/ATTACH]
I hope it gives you some keys.

No more success with true level triggering…

I have never gotten material detection to work. I always assumed it was broken, and has been for a long time.

Use properties instead. Make empties that sit over the points where the material is normally supposed to act as a trigger. Have near sensors (or maybe collision) on the player object detect properties on the empties. That should work.
Empties are invisible, so it should give the illusion to the player that the green squares (I assume green squares are what you’re aiming for) trigger a win situation (or however you have it set up there).

I think this does not work as there are several materials involved. I can remember that someone reported that quite a while ago. I never had a problem as I usually do not filter on materials but properties.

To solve the above problem I suggest to use a separate object for detection. I would add an invisible plane set to Physics type Sensor. It can detect the player on collision and perform the operations. Switching scenes does not need the player object anyway. So it is still good and efficient.

I hope it helps

ok it works.
I learn Collision, empty object, transparency and another tiny things : I should not follow step by step any tutorials if something else works :slight_smile:
With an invisible plane with material, my ray sensor works. You re right the problems surely comes from the two material on one object.
I don’t know who can change status to resolve.
Thx for your help guys.

you can … edit your top post in advanced mode ;).