instantreality forum
news: Welcome to the instantreality forums!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
January 17, 2018, 02:30:44 am


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Activate TimeSensor from ecmascript  (Read 1580 times)
pascal881
Newbie
*
Posts: 2


View Profile
« on: September 05, 2014, 08:36:47 am »

Hi i'm pascal881 and i'd understand how to activate TimeSensor from ecmascript, i'll explain you that i'd do, therefore i'd that when two object collide i turn on the TimeSensor so the second object start moving. There are the code :


 <TimeSensor DEF='tm'
       cycleInterval='4'
       loop='false'
       enabled='true'/>

  .....


    <Script DEF='script'>
    <field accessType='inputOnly' name='detect_position' type='MFVec3f'/>
     <field accessType= 'inputOnly'  name= 'set_fraction'  type = 'SFFloat' />

     <field accessType= 'outputOnly' name= 'value_changed' type = 'SFVec3f' />

....


 function detect_position(){

            var x=mano.translation.x;
            var y=mano.translation.y;
            var z = mano.translation.z;

            var h=mano2.height;
            var h2=ball2.radius;

            Browser.print("X = "+x+"\nY = "+y+"\nZ = "+z+"\nh1 = "+h+"\nh2 = "+h2+"\n");

            var x2=ball.translation.x;
            var y2=ball.translation.y;

            y2+=1;

            if(y < y2 + h2 && y+ h > y2){
                            //Browser.print("Collisione!!\n\n");
        ACTIVATE TIMESENSOR THAT MOVE THE SECOND OBJECT SO BALL
                            }


            }


this is a kind of dribble with a basketball.


Thanks a lot of.
Logged
LnD
Newbie
*
Posts: 3


View Profile
« Reply #1 on: April 13, 2015, 08:32:18 pm »

Hi There.

You can active the node TimeSensor, using:

 tm.enabled=true;

I hope help you!
Logged
pascal881
Newbie
*
Posts: 2


View Profile
« Reply #2 on: April 13, 2015, 08:38:39 pm »

Hi i have solved in another way, beacuse if i sue the way that you said me after instant Reality stop for ever the time sensor. Thanks whatever.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines