Create target point at coordinate

New releases and general discussions.

Post » Sat Sep 06, 2008 9:21 pm

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=
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Sun Sep 07, 2008 4:01 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon Sep 08, 2008 9:57 pm

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.
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Mon Sep 08, 2008 10:01 pm

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

and are there more of them?
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Mon Sep 08, 2008 10:27 pm

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
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Mon Sep 08, 2008 10:35 pm

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

id like to knwo how the pick functions work?
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Mon Sep 08, 2008 11:00 pm

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

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
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Tue Sep 09, 2008 4:53 pm

[quote="QuaziGNRLnose":2yhce8ms]oh yah, whats the distance/anglething do, never seen it before

and are there more of them?[/quote:2yhce8ms]
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!
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Wed Sep 10, 2008 4:08 pm

This works with more than one object, and is a bit more reliable (and faster) than checking collisions each frame :)
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Thu Sep 11, 2008 8:06 pm

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
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Next

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 1 guest