Rotate Object W/o Changing Direction

  • Possible for a sprite with bullet behavior or another way?

    Basically want to set random orientation at start, but still want it to go down or at 90 degrees with the bullet behavior.

    Just trying to introduce some randomness, so it all does not look so uniform.

    I've tried like 5 different things so far and nothing is working.

    I know it's possible with a player sprite via orienting toward the mouse cursor while moving in another direction.

  • i'm not sure i understand what you want.

    do you want enemies coming from top of the screen and go down but flying in weird pattenrs??or just spinning around?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well, all the sprites would be going down or at 90 degrees, but I want them oriented or turned at a random angle.

    So say you have a sprite in the shape of a cross, instead of all crosses looking nice and uniform, they would be rotated by various degrees but still heading down.

  • Animation frames?

  • With Bullet behaviour set the "Set Angle" property to no, then when you set the angle of motion the sprite wont move (change angle direction I mean).

  • GenkiGenga

    I tried that:

    I have a Sprite with the bullet behavior. I Set Angle to "No".

    Then:

    Sprite -> Rotate random (360) toward random (layoutwidth), random (layoutheight).

    Sprite -> Set Angle to 90

    And they're still all pointing upright.

    I tried Rotate Toward Angle, Rotate Toward Position, Set Angle, and Set Angle Toward Position all to no avail. All the sprites are still pointing straight up/down, the direction they're moving in.

    @klkitchens

    I also can't figure out how to pick a random frame for a sprite out of a set of its frames.

    I have a 54 frame sprite.

    I did a global or local FrameNo=0 for starters.

    Then:

    System -> Set FrameNo = floor(random(55))

    Sprite - > Set Animation Frame to FrameNo

    And nothing works.

  • Is this the kind of thing you are looking for?

    db.tt/gd9KSdf7

  • AmpedRobot

    dl.dropboxusercontent.com/u/7409023/construct/DropRandomFrame.capx

    Seems to work just fine.

    Made a sprite with just four frames, then Created the Sprite and set animation frame to floor(random(4))

  • Wow, thank you both.

    My mistake on randomizing the sprite angle was assuming any of the sprite set angle options would work correctly with the bullet behavior whereas apparently the secret with setting the angle to "no" on the behavior was then to use the Set Bullet Angle of Motion. The code example I had was with "yes" which used the default initial angle from the sprite's properties, so I thought that was enough even with the "no" setting. Things like that are not immediately obvious to a newbe.

    On the second example, for randomizing the frame, apparently using the random function directly in the Set Animation Frame was the secret as opposed to linking it to a global variable. Since it was a sub-action with a system repeat function I thought it would reroll the variable on every spawn, but apparently not.

    Programs are sometimes picky and this one incredibly so (but no more than several others I've been learning).

    In any case, thanks again. You saved me hours of experimentation and frustration I would have had to go through tomorrow and I will use these functions for many things.

    If we had a central repository of working, useful code examples (as opposed to just searching the forums, which is often a miss), that might be worth the price of the software or more.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)