1
$\begingroup$

I would like to make an object stay at the height (Z) and velocity it was created at (it's created from another object with an Edit object actuator). Ideally it should be allowed to bounce up/down, but not allowed to fall (think very slow light ray). I would like this object to bounce off only certain objects.

I couldn't get an object to do this with collision groups + physics (it seems like it should be possible though, so if it is, please say so :)

I thought I would try and handle bouncing with python, however I can't figure out how to get the normal of the face it hits on collision (I'm using a collision sensor with a property)

How can I get an object to behave like this?

Blendfile

$\endgroup$
8
  • $\begingroup$ Could you add your blend, I would try to add the ray sensor. But this might take a few days. $\endgroup$
    – stacker
    Commented May 22, 2014 at 20:44
  • $\begingroup$ @stacker Added .blend $\endgroup$
    – gandalf3
    Commented May 22, 2014 at 21:30
  • $\begingroup$ So far I tried to check the ray sensor independently from the collision sensor it sometime hit, made sure that the orientation (+Y) is taken into account (therefore I messed up the bullet obj). One issue is was the filter configured at the sensors you need a material or property called wall. I will give it another try, pasteall.org/blend/29396 for relfection using the normal see: blenderartists.org/forum/archive/index.php/t-177557.html $\endgroup$
    – stacker
    Commented May 23, 2014 at 6:27
  • $\begingroup$ @stacker Thanks. I do have walls (with a wall property), but they are set to wireframe (and are invisible when the BGE is run). They are on layer 3 $\endgroup$
    – gandalf3
    Commented May 23, 2014 at 7:34
  • $\begingroup$ In a simpler setup I noticed that a collision is only detected when the Physics Type of the object is set to sensor. Collision bounds are also required (but you have set them as I remember) $\endgroup$
    – stacker
    Commented May 23, 2014 at 13:33

1 Answer 1

1
$\begingroup$

You could try to use a ray sensor:

c = bge.logic.getCurrentController()
ray = c.sensors["raySensorName"]

if ray.positive:
    pos_vec = Vector(ray.hitPosition)
    normal_vec = Vector(ray.hitNormal)
$\endgroup$
2
  • $\begingroup$ Could you explain more? I'm rather new to the GE.. How would this work with collisions? Fire a ray on collision? How would I do that? Thanks :) $\endgroup$
    – gandalf3
    Commented May 22, 2014 at 6:45
  • $\begingroup$ I guess you add a ray sensor as well and when the a collision happens you can get the position and normal of the colliding face (the ray sensor casts rays on a selected axis and checks whether it hits something). I haven't used the ray sensor yet, this tutorial has a .blend file with scripts using the ray-sensor attached: youtube.com/watch?v=AXqXqLmsa1o $\endgroup$
    – stacker
    Commented May 22, 2014 at 7:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .