having trouble with sensors

40 views
Skip to first unread message

Lewis Lepton

unread,
May 25, 2017, 2:04:58 PM5/25/17
to Nape Physics
howdy folks,

i really like using nape. digging in much further into it. but sensors are really bugging me in many ways to get going.
ive followed everything that i can think of, even going to interacts, but those spit out WAY to many messages for what i need, i just need a single message to say that something has been touched/collided/sensed. collision has worked perfect, got that down, but sensing is something WAY diferent

i have tried to follow everything i can on this forum & stuff online, but am either getting lost in how people are discribing things or the implimintation of things. i doesnt help being disclecsic ;)
so some things that are spoken about, im having a bit of trouble actually understanding

but this is what i currently have right now. help would be really... errr... helpful ;)

im using haxe by the by if you were wondering, not as3. ive checked as3 demos but am coming up dry for sensors

class Project {
var goal:Goal;
var space:Space;
var ball:Ball;

var listener:InteractionListener;
var goalSensorCollisionType:CbType = new CbType();
var ballCollisionType:CbType = new CbType();
public function new() {
space = new Space();
goal = new Goal(space, 300, 300);
ball = new Ball(space);

listener = new InteractionListener(CbEvent.BEGIN, InteractionType.SENSOR, goalSensorCollisionType, ballCollisionType, collideGoal);
ball.body.cbTypes.add(ballCollisionType);
goal.goalFloor.body.cbTypes.add(goalSensorCollisionType);
 
space.listeners.add(listener);
}

public function collideGoal(callback:InteractionCallback){
trace('BLAHHH');
}
}


& inside the goal i am using a goal sensor to call up which has this set inside it
shape = new Polygon(Polygon.box(width, height));
shape.sensorEnabled = true;

thanks if someone can point me in the right direction. as its just beginning to go round in circles now

Lewis Lepton

unread,
May 25, 2017, 2:06:41 PM5/25/17
to Nape Physics
actually here is more of the goal thing

body = new Body(BodyType.KINEMATIC);
body.allowMovement = false;
body.allowRotation = false;
shape = new Polygon(Polygon.box(width, height));
shape.sensorEnabled = true;
body.shapes.add(shape);


Lewis Lepton

unread,
May 30, 2017, 5:04:02 PM5/30/17
to Nape Physics
nobody?

ive been trying since posting but its still not sticking or making sense to me to be honest

Lewis Lepton

unread,
May 30, 2017, 6:39:18 PM5/30/17
to Nape Physics
actually. think ive just stumbled across something. will post up my findings in a bit when i tidy things up

T1m_

unread,
Aug 23, 2017, 7:50:30 AM8/23/17
to Nape Physics
Here is the problem:


(BodyType.KINEMATIC);
body
.allowMovement = false;
body
.allowRotation = false;

I can't tell you more because it was a long time ago when I stuck with similar issue. But I believe the problem with these 3 lines. Since kinematic body not moves without explicitly setting its velocities, line 2 and 3 are needless. Try to remove them and see if it helps.
Reply all
Reply to author
Forward
0 new messages