Constrain rotation to touch

Can anyone tell me how to constrain the angle of an actor (crossbow) to touch, in a sweeping motion like a windshield wiper?

Any help much appreciated.

It’s not a bug – it’s an undocumented feature

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Something like this:

    when mousedown
    -- Constrain Attribute: self.rotation To: VectorToAngle(game.mouse.X - self.Position.X,game.mouse.Y - self.Position.Y)
  • Fal01Fal01 Member Posts: 460
    Thanks for your reply @RThurman,

    It works, but I can only control it from the side.

    Is there a way to control it from the middle? The actor is a crossbow facing the top of the screen and I need the touch position to be in the middle of the crossbow where the arrow is.

    Thanks again for your help.

    It’s not a bug – it’s an undocumented feature

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Not sure what you are asking.

    Does your crossbow (and arrow) graphic start at the '0' rotation? It should be facing directly to the right ----->
    That is the '0' direction.

    If it is not correctly oriented to '0' then the crossbow will not track the touch correctly.

    Hope that is what you are asking about!
  • Fal01Fal01 Member Posts: 460
    @RThurman,

    Sorry for the confusion, I am making a faux Z space crossbow facing the top of the screen.

    It’s not a bug – it’s an undocumented feature

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    So ... when you import the crossbow image, is it facing right --->
    The image needs to match the beginning orientation of the actor. It needs to face right.

    First, you import the image, and then place the image into the actor prototype. (It will be facing to the right.) Then you drag an instance of the prototype onto the scene and rotate it to face upwards.

    And then the equation will work properly.
  • Fal01Fal01 Member Posts: 460
    Oh, ok I'll try that.

    Thank's a lot for your help!

    It’s not a bug – it’s an undocumented feature

Sign In or Register to comment.