Math help - ORBZ this is probably one for you :)

jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
edited November -1 in Working with GS (Mac)
I've got some tricky math in my new game, and I've been trying to work with the sample projects, but it's over my head.

For the first part, I've been working with the canon shoot demo, but I don't want the full 90 degree range of fire. I want to limit it to just 45 degrees. So, if the canon is at a 45 degree angle from the ground, I want the canon to rotate no more than 22.5 degrees either up or down. The tricky part is that this can't be relative to the scene, it needs to be relative to the actor's position, as it could potentially be anywhere on a 360 degree sphere.

Secondly, lets say this canon shoots replicas of itself, and where the 'package' lands, it spawns a new canon, orientated the impact location, pointing out from it's own island at a 90 degree angle.

I drew this diagram to help illustrate it. Say island 1 is your starting place. The grey lines are the rotation range of the canon. you shoot at island 2, and it impacts, creating a new canon, with it's own range. I'm planning on making it so you need to select each canon to make it active.

Does that make sense?

image

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    thanks tshirt, that worked to limit, but I've still got to figure out how the current angle fits in there. When I have it apply to scene, it keeps it within a 0 to 45 degree angle. If I have it apply to actor, it just rotates counterclockwise every time time I click.

    time for bed anyways, i gotta get up at 5.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    so, i've kept working :)

    I attacked the angle slightly different. I'm capturing the existing angle of the actor upon start. Then I'm checking to see if self rotation stays between self.Angle+23 and self.angle-23 (this obviously doesn't take into account negative values.)

    This is what happens, I rotate to position as long as self.Rotation is smaller than self.Angle+23, so for example, if the angle is 45, it should stop at 68, but it's going to like 68.33, which makes the rule invalid and won't move again.

    I wish I paid more attention to math in college :)
  • ORBZORBZ Member Posts: 1,304
    I'm not clear, do you have a sample project?
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    I'm actually attacking this from a different angle now. Have you seen the game JumpOClock? I'm looking for something like that. And this is probably much easier, but im at work and can't open gs for a few hours. I want to launch something at a rotating sphere, when it hits the sphere i want it to latch on and rotate with it.

    Here's a gameplay video of jumpoclock
Sign In or Register to comment.