2 Replies Latest reply on Oct 31, 2006 9:24 AM by ensamblador

    RE-rotate

    newmfa
      Hi, all
      I have a scene include only one cast member called "cube" and this cast member include model called "red", all my need to do is "when I click button ...

      if model "red" in position (50,0,0) rotate it 180 degree around (0,0,0) world point.

      when I click again same button do that..

      if model "red" in position (-50,0,0) rotate it 90 degree around (0,0,0) world point.

      I tried next code, but not give me right result..

      on mouseup me
      if member("cube").model("red").transform.position = vector(50,0,0) then
      member("cube").model("red").rotate(0,0,180,#world)
      end if
      if member("cube").model("red").transform.position = vector(-50,0,0) then
      member("cube").model("red").rotate(0,0,90,#world)
      end if
      end

      I need know where my wrong in my code!!

      newmfa
        • 1. Re: RE-rotate
          duckets Level 1

          Check it out: http://robotduck.com/misc/rgb

          Is this what you're after?

          (this movie is adapted from one that the original poster posted to the doug forums)

          This is what I've done:

          * Reduced your sprites down to one frame, and put a 'loop' behaviour on that frame.

          * Used a general-purpose 'sendallsprites' behaviour on the 3 buttons, so each button sends a call for the handler "changeColor", each with its own colour name as the argument sent to that handler.

          * Put a behaviour on the 3d scene (called 'world bhv'), which creates a group and sets it as the cube's parents. This way, you can rotate the group and the cubes rotate with it. This is called 'rotate pivot'.

          * The 'changeColor' handler (in the world behaviour) sets a value called "rotateDestination" based on what color name is received as the argument. This is the angle to which the rotate pivot must turn to.

          * Each frame, it checks whether the current angle of the rotate pivot ('r') needs to be adjusted, to move towards the rotateDestination value. If so, it increases or decreases the 'r' value by a small amount until it reaches the rotateDestination value.

          Hope this is all clear! (source code is linked at the page above)

          - Ben

          • 2. Re: RE-rotate
            ensamblador Level 1
            tip:
            what if if member("cube").model("red").transform.position = vector(50.0001,0,0)?