Math help - ORBZ this is probably one for you :)
jonmulcahy
Member, Sous Chef Posts: 10,408
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?
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?
Comments
time for bed anyways, i gotta get up at 5.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
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
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Here's a gameplay video of jumpoclock
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left