Creating a "Line"

I'm super confused right now on something that I believe to be a simple fix...

Imaging a fishing line; so I have 3 actors: A "rod", a "hook" and a "line"

I want the player to tap and the "hook" and "line" are cast out, the "rod" stays stationary (it is a hard-position)

I've been watching the Cookbook "Create a Line" video a number of times and I'm getting so confused...

I want the actor to change widths based on the way the line goes out (thus, it gets longer the farther away the "hook" goes) and when it's reeled in the line gets shorter and shorter.

I'm super confused with variables here...can someone help please?

Comments

  • DrGlickertDrGlickert Member Posts: 1,135
    Okay, here's where I am now;

    I have the line changing width's correctly. However, I've got it spawning at a fixed point on the scene.

    I'm assuming that by using two Constrain Attributes I can achieve what it is that I want;

    Constrain self.position.X to
    Constrain self.position.Y to

    What do I put in there?

    Basically I'm asking how to maintain a point directly between two points where one is moving and one is stationary...

    SO; how do I find the constant middle point between two points where one is moving...
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    First you need to constantly update four attributes that represent the x,y positions of actor1 and actor2. I'll call them A1X,A1Y and A2X,A2Y (for actor 1 and actor 2, respectively).

    Then you will need to constantly update the line actor in four ways:
    Constrain Attribute: self.width To: magnitude( game.A1X - game.A2X , game.A1Y - game.A2Y )
    Constrain Attribute: self.rotation To: vectorToAngle( game.A1X - game.A2X , game.A1Y - game.A2Y )
    Constrain Attribute: self.Position.X To: game.A1X +( game.A2X - game.A1X )/2
    Constrain Attribute: self.Position.Y To: game.A1Y +( game.A2Y - game.A1Y )/2

    That should do it!
  • DrGlickertDrGlickert Member Posts: 1,135
    That totally worked. You're awesome! Thanks for the help!
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Glad its working for you!

    Its kind of a neat effect. So I decided to put it into Stormy's thread of useful equations.
  • Game_AppAdGame_AppAd Member Posts: 10
    Hi Glickert,

    Can you kind enough to share your file? or the link for Cookbook "Create a Line" video ?
    Many thanks.
Sign In or Register to comment.