Ok, bit of Maths help if you please. Target the end of a shape.

StormyStudioStormyStudio United KingdomMember Posts: 3,989
edited November -1 in Working with GS (Mac)
Working on my 2 week project 'Escape Artist'.

I'm struggling to find the right set of rules to achieve what I need.

I've got a setup so an actor needs to follow the path you draw. As it arrives at the last part of the drawn line, it travels half way along the last actor. I want it to travel all the way along the last actor to the end. Rather than to the middle.

How can I find the furthest right X and Y position of an actor that is rotated to an unknown angle,

e.g. A line with a width of 100 pixels is rotated clockwise 42 degrees. How do I find the x and y position of its furthest right point at the end of the line.

Its probably using 'VectortoAngle', 'selfwidth/2' , self position X, self position Y... I just cant get it right...

Many thanks for any help...the game although simple should hopefully be quite addictive.

(I've used my own set of rule to create the tracking of the drawings, and recently changed it from spawned dots to lines after looking at Orbz great line drawing demo..)

Comments

  • AsymptoteellAsymptoteell Member Posts: 1,362
    Y: sin(self.rotation)*1/2*self.height or width, whichever one is long.

    X is the same thing but with cosine.
  • AsymptoteellAsymptoteell Member Posts: 1,362
    Sorry. Both are added to the self.positionY and/or self.positionX.
  • HachikoHachiko Member Posts: 330
    Can't you spawn a "last" point when player touch ends? Meaning, you use all the spawn line code, then when player lift the finger (so they finished to draw their path), another one is spawned where the player lifted the finger (so it should be at exactly the furthest right X and Y position of the last line spawned). You can store the last touch.x and touch.y too for this, and let the actor follow the degree of the line but ending at the last touch.x and y stored in the attributes.
    Not sure if I understood clear though, so this may be not possible depending on how you're handling everything. Math is cool too, but I prefer to use one system for everything, without mixing xP
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    @hachinko, I already tried what you said as it made sense, but get mixed results as I try draw the line quickly and let go the last line still has some width to it. Maybe if I spawn another dot after a timer it might work better, but then it starts interfering with other rules about line completion etc.

    @asymptotell I'll give that a go at lunch today., thanks very
    Much. I need to brush up on my sin and cos, I started watching some khan academy on youtube, just news to remember what I hear. :-)
Sign In or Register to comment.