How do I rotate an object without using the rotate behavior?

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • The object in question uses a bullet behavior. I'm wondering if there is a way to code the angle of motion such that the ensuing angle continually adds/subtracts to make the object rotate. An attempt to do this on my end was... unsuccessful.

    Any help, as ever, is appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What have you tried? There is a rotate action for the sprite object. Run that every tick and it will rotate and change the angle of motion of the bullet behavior. You can just fiddle the number till it’s rotating a satisfactory rate. You can also incorporate dt so it will rotate consistently no matter the frame rate. For example rotating by 100*dt will make it rotate 100 degrees per second

  • See, I had a feeling I was trying it the wrong way.

    What I tried to do was add a certain amount (let's keep it at 100 deg for example) to a formula already existing so that it could alter the angle.

    What I'm trying to do is a quadrifolium path with the sprite already spawning at one of its arms (the far ends of the four-leaf clover shape.) I'm also not trying to make the sprite look like it's rotating while it does so.

    Hence, I chose the bullet instead of rotate behavior.

  • Have you tried not using a behavior and moving the object directly with the polar equation r=a*cos(2*theta)?

    Something like:

    Var theta=0

    Var rot=0

    Every tick

    — sprite: set position to 320,240

    — add 30*dt to theta

    — sprite: move 200*cos(2*theta) pixels at angle theta+rot

    That will move it along the path and it starts on a leaf. You can rotate the whole path with the rot variable.

    You can also change the angle of the sprite to be at the angle its moving by saving the old position before moving and setting the angle to angle(prevX,prevY,x,y) after you move it.

  • Have you tried not using a behavior and moving the object directly with the polar equation r=a*cos(2*theta)?

    Something like:

    Var theta=0

    Var rot=0

    Every tick

    — sprite: set position to 320,240

    — add 30*dt to theta

    — sprite: move 200*cos(2*theta) pixels at angle theta+rot

    That will move it along the path and it starts on a leaf. You can rotate the whole path with the rot variable.

    You can also change the angle of the sprite to be at the angle its moving by saving the old position before moving and setting the angle to angle(prevX,prevY,x,y) after you move it.

    I might be missing something... the sprite is not behaving the way this is intending. I think it may be because I haven't gotten rid of the bullet behavior yet. But it's hard to tell.

    I can provide my code upon request.

  • Here's an example. I think it's cool the planes never collide.

    dropbox.com/scl/fi/yzoz4teghe9etfoa2qml8/flower_path.capx

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