how to make a cannon variable fire strength
tollhousestudio
Member Posts: 166
what I'm trying to do is create a cannon, with a bar that moves up and down and when you tap, it fires at the strength that is in the bar.
Does that make sense?
not hold down to get whatever strength you want, tap to try and catch it at full strength.
This would be tasty if you could help.
Does that make sense?
not hold down to get whatever strength you want, tap to try and catch it at full strength.
This would be tasty if you could help.
Comments
Every .01 seconds set power + 1 if up is true, and power - 1 if up is false.
Also check that if power >= 100, set up to false, and if power <= 0, set up to true.
so you will need 4 attributes in the bar Actor:
minHeight
maxHeight
scaleDirection
scaleSpeed
enter in the minimum Height of the bar, as well as the maximum height (these are in pixels)
scale Direction will be an integer, either 1 or -1, set it initially to 1
scale speed is the speed in which the bar grows/contracts, play with this setting until you like it.
Create a timer:
EVERY 0.01 seconds
Change Attribute: self.Size.Height To: self.Size.Height + (self.scaleSpeed * self.scaleDirection)
Create two Rules:
When self.Size.Height >= self.maxHeight
Change Attribute: self.ScaleDirection To: -1
When self.Size.Height <= self.minHeight
Change Attribute: self.ScaleDirection To: 1
Finally, within the Timer, you will put another Change Attribute.
This is where you will set your global game attribute called "power" or whatever.
Set this to be some ratio of the height of the bar, or just the height itself.
Hope this helps!
Joe
I'm kinda struggling.