seemingly simple angle issue....

Get help using Construct 3!

Post » Sat Jun 17, 2017 9:01 am

so im making a game, think something along the lines of hungry hungry hippos. you click, object rises up, grabs, etc. i have the whole grab thing down to if clicked spawn grabber, if not clicked destroy, and on created set position to (mouse.x,mouse.y), but it only grabs straight up. when i try to angle it from the bottom center of the screen (i have a box there) it goes all over. ive tried angle(mouse.x,mouse.y,box.x,box.y) , and vice versa, but it seems to give me opposites. if i click on the left it spawns on the right, if i click on the right it spawns on the left, and if i click above, it spawns a flat line in the middle. while it makes for some cool designs, im looking for the object to spawn on the mouse, aimed towards the bottom center of the viewport, so that it always starts at the center, and ends at the mouse cursor. any help or suggestions would be appreciated.
B
23
S
12
G
1
Posts: 109
Reputation: 2,801

Post » Sat Jun 17, 2017 9:53 am

Hi @the_Shit_hawk (nice username - Lahey would be proud! :) )

I wasn't exactly sure what you were after so I've included two schemes in this demo:

https://www.dropbox.com/s/umqh6cnvtwuh3 ... s.c3p?dl=0

Just re-enable the second event and disable the first to switch.

I've set the hippo to invisible rather than destroy it, which should be a teensy bit faster at runtime - you would probably want to disable the collisions when it's invisible too.

Hope that helps! :)
B
20
S
9
G
4
Posts: 473
Reputation: 4,260

Post » Sat Jun 17, 2017 9:59 am

One thing to note when using angles: when you look at sprite in the editor, 0 degrees actually points to the right rather than straight up, so you need to take this into account when using things like the angle(X1,Y1,X2,Y2) function. Check out how I've set up the hippo sprite and its origin in the editor to see what I mean.
B
20
S
9
G
4
Posts: 473
Reputation: 4,260

Post » Sat Jun 17, 2017 10:42 am

awesome. so it seems what i was doing wrong, was that i had the image point at the top of a vertical rectangle instead of a horizontal one. i dont know why i didnt think of invisible instead of constantly creating/destroying, i think its because i started out with bullet behavior. you can use a combination of emitters with the sine behavior and platforms with solid and bullet behaviors to make 'randomly' generated platforms/sprites
B
23
S
12
G
1
Posts: 109
Reputation: 2,801

Post » Sat Jun 17, 2017 10:43 am

thank you much
B
23
S
12
G
1
Posts: 109
Reputation: 2,801

Post » Sat Jun 17, 2017 10:59 am

You're welcome :)
B
20
S
9
G
4
Posts: 473
Reputation: 4,260

Post » Sat Jun 17, 2017 7:40 pm

another angle question; im trying to set bullet angle of motion between the angle of 315, 45 if A, 135,225 if B. B is easy as its random(135,225) , but upon typing in random(315,45) i realize theres no way for the engine to know what the max number is, even though it IS angles. so i guess my question now, is how would i set it to pick a random angle between 315,360 - OR - 0-45 ? to work around it ive made 3 variables, but i was curious if there was a way to range angles like that
B
23
S
12
G
1
Posts: 109
Reputation: 2,801

Post » Sat Jun 17, 2017 8:04 pm

Easy.
random(315, 360+45)

Anything that takes an angle will be fine with that. Or if you want to keep it in range you can do:
random(315,360+45)%360
B
94
S
33
G
113
Posts: 5,354
Reputation: 73,269

Post » Sat Jun 17, 2017 8:35 pm

this is what i have at the moment, https://www.dropbox.com/s/ne9f19hs6dray ... n.c3p?dl=0 , theres 5 variables to even out the left/right spawning, but if i could narrow that down to 1 or 2 events itd be nice. events in question are 14-18
B
23
S
12
G
1
Posts: 109
Reputation: 2,801

Post » Sun Jun 18, 2017 9:00 pm

R0J0hound wrote:Easy.
random(315, 360+45)

Anything that takes an angle will be fine with that. Or if you want to keep it in range you can do:
random(315,360+45)%360


Forum won't let me PM you. I have a question about a reply you made on here back in 2014, found here viewtopic.php?f=147&t=97994&p=1128268#p1128268. Do you still have that CPX for gravity simulation? I'm making a game using 2-body orbital mechanics and would love to take a peek, but the dropbox link is down.
B
4
S
2
Posts: 4
Reputation: 408

Next

Return to How do I...?

Who is online

Users browsing this forum: No registered users and 3 guests