seemingly simple angle issue....

0 favourites
  • 13 posts
From the Asset Store
3D Car Pack 1
$1.80 USD
40% off
3D models + Rendered Low-Poly Cars in isometric, top-down, and side angles.
  • 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.

  • Hi the_Shit_hawk (nice username - Lahey would be proud! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> )

    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! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • 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.

  • 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

  • thank you much

  • You're welcome

  • 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

  • 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

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • > 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.

    For the simulation, are you interested in a deterministic model, or a numerical approach?

    I.e. -- Do you want everything to be parametrically-determined parabolas, or do you need acceleration to be computed dynamically based on forces?

    Deterministic approach:

    https://www.simbucket.com/simulation/orbital-motion/

    Forces approach:

    https://www.simbucket.com/simulation/satellite-motion/

  • >

    > > 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.

    >

    For the simulation, are you interested in a deterministic model, or a numerical approach?

    I.e. -- Do you want everything to be parametrically-determined parabolas, or do you need acceleration to be computed dynamically based on forces?

    Deterministic approach:

    https://www.simbucket.com/simulation/orbital-motion/

    Forces approach:

    https://www.simbucket.com/simulation/satellite-motion/

    If I correctly understand your question, the context of my game requires it to be the Forces approach. I will have dynamic mass, thrust, direction, etc for the player's ship. Best case scenario is this: I have a stationary star, some planets orbiting that star, and a few moons orbiting some of the planets. If a player could use their semi-customized ship (mass, thrust, throttle capability, etc will all be dynamic based on player choice) to leave orbit of the 'home' planet and rendezvous with another orbiting body that would be my goal.

  • the_Shit_hawk

    It took me a while to open that, and I don't see any pattern other than most of them have the same action.

    travdoty

    I do, but I'll post it to the other topic. It's probably not the best idea to hijack someone else's topic to get a hold of me.

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