Create target point at coordinate

This forum is currently in read-only mode.
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • ok this is a little hard to explain, lets say you had to make an object "stick" to a spinning/moving object, depending on where it hits it. what would you do? you could set up a massive mess of code to do this. what i mean is object a hits a spinning object, normally to make something stick you would make it always set position to an image point, but if you need to make an object stick at a relative point to a spinning object based on where it hits you would sorta of need a create image point on spriteX at coordinate. this is basically what im asking for. its useful for many things when u need something to stick like this, which i believe many other people have thought of doing but gave up on it because there was no way of doing it. it could be used for lots of things, which need to be actively changed within the game, such as if you wanted the player to be able to attach a weapon anywhere on a ship, and make it stay there, or if u wanted a grappling hook to stick to any object spinning, rescaling, or moving.

    if it were to be implemented essential features would be

    [create image point at]

    name=

    x= ;these should be relative to the layout not the object, because you want it to lets say be at sprite.x

    y= ;these should be relative to the layout not the object, because you want it to lets say be at sprite.y

    [delete image point]; this is for when lets say you detach a grappling hook, you wouldnt want the image point to stay where it initially was created, you'd want to destroy it so you can attach to a new location

    name=

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This would be a nice feature. In the meantime, here's the maths you need.

    When A collides with spinning B and you want A to stick on to B, first calculate the distance and angle offset from B to A and store these in private variables, eg.

    Set 'dist' to distance(B.X, B.Y, A.X, A.Y)

    Set 'ang' to angle(B.X, B.Y, A.X, A.Y) - B.angle

    then, from then on, always set A's X and Y co-ordinates to

    B.X + cos(A('ang') + B.angle) * A('dist')

    B.Y + sin(A('ang') + B.angle) * A('dist')

    I can't check this works right now but its the right idea. Some kind of 'Stick' feature would definitely be useful instead of this though.

  • freak i always need damn sin,cos,tan wtv and i KNOW that its what i need to find angle relations but damn it, I HAVNT LEARNED IT YET(im mad at myself here lol) D: i cant wait till i do tho (1 year!), and thanks for showing me that, i knew i needed to use those, and if no one helped id never been able to figure it out . anyways ill try it out and tell u my findings, glad to see you think its a good idea, its one of those things that U ALWAYS need and have to work around, but what i like about construct is i never have to work around anything to achive my goal. eventually i will make an uber awesome game too show those ppl at the Daily click just how awesome construct is (it's pretty damn awesome xD) i hate the way they blatantly insult a program which IMO is the best game creator out there and for free, i dint believe it at first, man you dont know how happy youve made us ppl who just dont have the money to buy 120-250$ programs which they dont need but the hoobysist inside is like "GET IS YOU FOOL". construct really needs to be demonstrated tho, i think you guys need to show it at some indie game convention, they think game maker is GOOD which is soo overated, it really deserves more attention, its awesome in its pre release stage, cmon AWESOMEE.

    so yah another one of my drift offs into nowhere.

    glad to see this feature is getting your attention, its perfect for the grappling hook i'm making it using sin! which ,means my bro helped me figure it out a bit., (i should really post it, although all it does is swing and release atm, can figure out how it should shoot out again once its refired) but this like most of my suggestions it's more about the general public who can use it , after all i dont want you making my game for me,i know ppl will use it if its there.

  • oh yah, whats the distance/anglething do, never seen it before

    and are there more of them?

  • ah, it works perfectly

    http://www.2shared.com/file/3898030/15dabe8a/STICK.html

    press new to "unstick" and then repeat

    oh yah you click too position, but it only works if its not already stuck

  • hmm, seems that it cant recognise different instances of the same rotating circle though,

    id like to knwo how the pick functions work?

  • oh god, quadruple post, why does the edit time out WHY??

    guess i got it to work with multiple instances by adding a selector variable, to the rotating object. which is set when an object is attached. i can see this stick function as being easy enough to implement. but i think it would be easier for it to create one imagepoint whith, which you can delete, because it would be less taxing on the processor, im sure running lots of these functions would eat your framerate, especially on slower machines,or where you have lots of intense calcs going on

    also you could always use this if u wanted to do it this way, but you could never create an image point using events

  • oh yah, whats the distance/anglething do, never seen it before

    and are there more of them?

    All system expressions can be found by double clicking the system object in the object panel in the parameters dialog - or look up 'System Expressions' on the Wiki.

    If you have two points - (x1, y1) and (x2, y2), distance(x1, y1, x2, y2) gives the distance between the two points, and angle(x1, y1, x2, y2) gives the angle between them.

    I'll come back to this when I have an internet connection installed in my house!

  • This works with more than one object, and is a bit more reliable (and faster) than checking collisions each frame

  • yah, i got it to work like that too after adding a a value to the picked lock-on, which makes it work fine with lots of instances, except there should only be 1-2 attached objects on each circle or it goes all wierd

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