How do I rotate an object around its own Y axis? [SOLVED]

Not favoritedFavorited Favorited 0 favourites
  • 12 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi guys!

    I tried so many times here, but I didn't (image below). :(

    These tests above even work, but the object simply disappears when it rotates 180 degrees!

    How do I rotate an object in C2 along its own Y axis (without having to resort to animation)?

    Thanks in advance! :)

  • Hello friend, do you have a animation of what you are trying to achieve?

    im confused by trying to understand what you mean by rotate around its own Y axis?

    is it a 3d game ? or effect?

    top down view?

    usually X axis left right Y axis forward backward Z top down.

    so u see why my confusion ...

    in C3 default camera is top down, or sideview... depends who u ask...

    so rotate works as intended rotates from origin or "center" point of sprite clockwise or counterclocwise as u experienced, what you want i think considering is a "leaf" animation correct me if im wrong>>>

    you want the leaf to fly straight then make a round trip then continue its journey? like a gust of wind? or what is the final achievement?

  • Probably just:

    Var rotY=0
    
    Every tick
    — add 50*dt to rotY
    — sprite: set width to self.originalWidth*cos(rotY)

    Also it’s probably not necessary to post the question twice in both the c2 and c3 sections. The forum is already slow and most just look at new posts so they’ll see the question no matter where you post it.

  • Probably just:

    Var rotY=0
    
    Every tick
    — add 50*dt to rotY
    — sprite: set width to self.originalWidth*cos(rotY)

    Also it’s probably not necessary to post the question twice in both the c2 and c3 sections. The forum is already slow and most just look at new posts so they’ll see the question no matter where you post it.

    oh that make sense. like a flip/flop thingy

    as a patch to r0j0s input, for me works with this bellow, i think he wants to do exactly what u shown r0j0 in ur code which makes sense don't know i was thinking at gusts of winds lmao, but if using Width makes sprite stop at 0 while sprite can take negative values is a bit weird to convert, but as originalWidth since is not a function yet in regular eventsystem basically he can use ImagePointY(0) (if the 0 is the default of that sprite)

    Var rotY=0
    
    Every tick
    — add 100*dt to rotY
    — sprite: set width to self.ImagePointY(0)*cos(rotY)
  • Hello friend, do you have a animation of what you are trying to achieve?

    im confused by trying to understand what you mean by rotate around its own Y axis?

    is it a 3d game ? or effect?

    top down view?

    usually X axis left right Y axis forward backward Z top down.

    so u see why my confusion ...

    in C3 default camera is top down, or sideview... depends who u ask...

    so rotate works as intended rotates from origin or "center" point of sprite clockwise or counterclocwise as u experienced, what you want i think considering is a "leaf" animation correct me if im wrong>>>

    you want the leaf to fly straight then make a round trip then continue its journey? like a gust of wind? or what is the final achievement?

    I'm using C2 and it's a 2D platform game. :)

    I'm trying to implement a falling leaf effect.

  • Probably just:

    Var rotY=0
    
    Every tick
    — add 50*dt to rotY
    — sprite: set width to self.originalWidth*cos(rotY)

    Also it’s probably not necessary to post the question twice in both the c2 and c3 sections. The forum is already slow and most just look at new posts so they’ll see the question no matter where you post it.

    Since i'm using C2, I try to use just your code (disabling everything else shown in the attached image above), but the leaves disappear as soon as they turn 180 degrees. :(

    C2 doesn't have the "originalWidth" function, so I replaced it with self.Width.

    PS.: Sorry for the duplicate post. ^^

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What I'm trying to implement here is an effect of leaves falling randomly from the top of the screen (tree canopy). The rotation around the Y axis itself is to simulate three-dimensionality in a 2D game.

  • You don’t want to use Sprite.width since it’s changing. Worst case just use a fixed number such as 64 or whatever width you want it to start at when not rotated.

    I guess it’s sprite.ImageWidth not originalWidth.

  • You don’t want to use Sprite.width since it’s changing. Worst case just use a fixed number such as 64 or whatever width you want it to start at when not rotated.

    I guess it’s sprite.ImageWidth not originalWidth.

    It worked! :D

    Thank u one more time!

    You're awesome!

  • R0J0houndSorry to bother you again, but what do you suggest I do to create a random behavior of leaves being blown away by the wind?

    I tried here using Sine and Rotate, but I still didn't get the randomness we see in nature. :(

    PS.: I tried with Particles, and it didn't worked well too.

  • It’s probably not random.

    You sound like you have a specific behavior you’re after that you have footage of or have seen. You could start by examining the motion of one leaf and trying to break it down into a path that you could replicate somehow. Worst case you could maybe use a timeline to manually plot a path. With two or three varieties you may get enough variation.

    At the other end of complexity you could try some grid based fluid dynamics to model airflows. Then the leaves would move based on where they were within it since you would have velocity at any point. Then you could model the leaves as slightly curved apply the wind to them based on the angle the wind hits them.

    There are probably many options in between. I don’t have any specific examples in mind though.

  • It’s probably not random.

    You sound like you have a specific behavior you’re after that you have footage of or have seen. You could start by examining the motion of one leaf and trying to break it down into a path that you could replicate somehow. Worst case you could maybe use a timeline to manually plot a path. With two or three varieties you may get enough variation.

    At the other end of complexity you could try some grid based fluid dynamics to model airflows. Then the leaves would move based on where they were within it since you would have velocity at any point. Then you could model the leaves as slightly curved apply the wind to them based on the angle the wind hits them.

    There are probably many options in between. I don’t have any specific examples in mind though.

    Ok, dude. I'm doing some tests here. Thanks one more time for you help. :)

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