two different movements at the same time
RossmanBrothersGames
Member Posts: 659
hey everyone, I am working on a project where my character runs around a round circle like a planet, think something like a 2d mario galaxy. I have the character always accelerating at the center of the planet, and I have his rotation constrained to the angle he is at to the planet so he is always on his feet.
Here is my problem. I have the character able to run both directions and jump. However if I jump and am holding the button to move sideways my character will not move down since the acceleration is overridden by the command to move sideways.
Not sure how to fix this, I can't use linear velocity since my character is moving around a circle, wish that you could have accelerate and movement both happen at the same time...
Comments
I'd simply interpolate the actor up and down for the jump . . . .
Example:
thanks @socks however do you have any thoughts on controlling the left and right movement outside of the physics. Reason being the more complicated stuff is going to be the up and down, I plan on double jumps and enemies hitting you into the air at different velocities and gravity pulling you back, maybe even multiple hits in the air.
I'm wondering if there is a way to figure out the x,y coordinates to the left and right of you depending on the angle and changing your position to those over and over again or something like that
www.rossmanbrosgames.com
p.s. love the second video
www.rossmanbrosgames.com
I don't know what that means.
I figured it out using the COS and SIN to add or subtract to the x and y position over and over when you hold the right and left buttons down, but it was too choppy, I think I will need to make it work with your method, thanks for all the help!
www.rossmanbrosgames.com
You can constrain the object to the cos and sin of an angle instead, which will be very smooth.
Constrain X position to radius * cos (angle) + X pivot point
Constrain Y position to radius * sin (angle) + Y pivot point
. . . and just have the left and right keys change the angle.
Example file attached:
Space bar = jump
Left Arrow = CCW
Right Arrow = CW
wonderful!!
@Socks These are brilliant!
Weird !? I'm always surprised at what people are taken by, you spend hours fiddling around with some way to get the actor to change its colour based on the current Euro to Dollar exchange rate using the phase of the moon and wind speed in the North Atlantic to modify the rate of updates . . . and you get a 'meh' . . . but move an actor in a circle and people are amazed ! Lol
You under-rate your prowess, good sir. Anything that I don't know how to implement so elegantly in GS amazes me, especially when it triggers an idea in my mind about a whole game based on one short tutorial.
As I have mentioned elsewhere in the forum, the core group of long-standing Pro Members like yourself, who contribute so generously with code and tutorials to further our skills, are greatly appreciated.