How do you make an actor react in a parabolic fashion against gravity?
CoolBee
Member Posts: 81
I'm wanting to shoot an actor upwards in the air at say 75 degrees then slowly rotate to downwards of 25 degrees as gravity overcomes the upwards acceleration a bit like a parabolic curve is there anyway to do this?
Kind Regards
John
Kind Regards
John
Comments
Accelerate, direction 270, acceleration 300 (or whatever fits your game), relative to screen. (This will act as gravity on the actor, you could also use the overall scene gravity but I prefer this method).
Then when some condition is met, maybe pressing a key. Use:
Change Velocity, direction 75, speed 300 (or again whatever fits your game), Relative to scene.
Thats' one way.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
constrain actor.rotation = vectorToAngle(actor.linearVelocityX, actor.linearVelocityY)
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
If your actor is moving based on physics - i.e. it's moved because something else bumped it or because it's using the Change Velocity or Accelerate or gravity behaviors do this:
Inside the actor add the following line:
Constrain Attribute self.rotation = vectorToAngle(self.motion.linearVelocityX, self.motion.linearVelocityY)
This presumes your actor "front" is facing right by default, i.e. 0 degrees.
i'm going to upload an example... one sec.
Attached is an example project that shows what i'm talking about.
Now I've tried to move over the rules from your scene but I can't replicate it while keeping him in the same position, Sorry for all the trouble btw!
In that case you need to have your actor face in whatever direction the background is scrolling + 180 degrees.
If I'm right this will work.
Rule
If attribute self.linear.velocity.Y > 100
Change attribute self.rotation to 25
Rule
If attribute self.linear.velocity. Y < 100
Change attribute self.rotation to 340
So if it takes a velocity of 100 or higher to make him go up the bird will face up a bit and when the velocity falls below 100 he drops and the bird will face down. This should get you thinking of ways to do it.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
If what @FryingBaconStudios is saying is correct - namely that you're actor moves up and down based on LinearVelocityY but doesn't move left or right and instead the background moves left and right - Then what he said will work. However, here is a simpler and more precise method that doesn't need as many rules and tilts more as the bird travels up/down faster and less as the bird travels up/down slower. This will create the illusion of a perfect parabolic arc even though you are not actually moving.
Inside the bird actor do this:
Define tiltDegreesMax = 45 (set this to whatever looks best for you)
Constrain self.rotation = self.linearVelocityY / self.maxVelocity * self.tiltDegreesMax
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
"Coding is all just about monitoring and changing variables and conditions."
Check out functional programming then -- it's most certainly not like that.
http://en.wikipedia.org/wiki/Functional_programming
GS is a form of event driven programming
http://en.wikipedia.org/wiki/Event-driven_programming
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS