Wednesday 18 March 2009

If Statements

Hi Nick

We are having problems with 'if' statements.  What we want to do is set up an expression which will determine the positioning of an object in relation to the range of values which we have set.  For example, if (sensorvalue) is less than or equal to x, AND more than or equal to y THEN position the object at position z.

Here are the expressions we have tried which aren't working!:

1.

if ((sensorInput.sensor3<=300)&&(sensorInput.sensor3>=250))
{
select -r pCube1;
move -r 50 0 0;
}

2.

if ((sensorInput.sensor3<=300)&&(sensorInput.sensor3>=250))
{
pCube1.translateY = 50
}



Any ideas?

Thanks

Mark

2 comments:

  1. What exactly isn't working is it giving you an error or just not placing it where you want it to?

    As a guess - unless you changed the remap function the sensor3 value will be between 0 - 1 so your if may not ever be true

    ReplyDelete
  2. Hi Nick,

    The problem is that nothing happens at all when we use this code. Are either of those two attempts correct? Should they work? Basically the box doesn't move. We've tried messing about with the input/output settings and with the value that the box should move, but nothing seems to work.

    What is the remap function and how to I change that?

    thanks

    ReplyDelete