Complex movement within animation - apache-flex

I've this application, where two children are playing catch. One throws and the other catches. While I can show a ball object moving between two stationary objects, how do I show the objects "releasing" and "catching" the ball, in a way that is close to lifelike?
EDIT:
The movement of the hands in this game: http://www.acreativedesktop.com/animation-game-slaphands.html is what I would like to replicate. Any tips on how to do that?

As it's already been stated, you need animation to get it right. I suggest looking over Preston Blair's Cartoon Animation Book or The Animator's Survival Kit. You won't need to read the whole thing, just reference the chapters on anticipation and accents.
For example, when one throws, the action doesn't just happen, one first prepares, anticipating the throw, building up energy. In animation you prepare the viewer for the next action, thus creating a seamless link between actions. Once the ball is thrown...there is action and re-action, so the player will return to his casual pose.
The actionscript part should be pretty simple. You should get away with 3 vectors:
1 for setting the balls movement
1 for gravity
1 for friction/wind...etc.
Based on your parameters, you launch the ball, then use the distance between the ball and the catcher to figure out when you can you play the catcher's animation(s)

skeletal animation is a good technique
also reverse kinematics
or even motion-capture

I know this is essentially possible in flash... it does however sound pretty complex. My advice would be to create static animations for the throw action and the catch action, then have these actions play when certain conditions are met (i.e. the ball gets close to one of the people). Trying to get a lifelike throw and catch will be pretty tough. I would think even a lot of console games wouldn't attempt to do this dynamically (i do expect this is in the process or is changing in current gen games)

Related

Is there a wait function in GML?

I've been trying to make my code work for some time, but I can't seem to find a way to make it work, specifically, I can't find a way to make an object wait in an if statement or find a viable alternative to one.
Essentially, I've been trying to make a game object move to the right for 2 seconds, and then go back to it's original coordinates once that movement is finished.
I'm pretty new to GML, but I figured something such as x += 2 was what i was searching for in terms of moving the object to the right. However, I can't find a way to make said object execute x +=2 only once once pressing the control button (because it keeps sliding to the right as long as I press it, it doesn't just make a swift movement to the right), then wait in place for 2 seconds. I've tried making if statements as intricate as I could make them, but to no avail.
If anyone has any idea, i'm excitedly open to it.
Have a good day.
You are probably looking for a timer, to let the object wait before an action. In that case, this question may help: Delay time in GMS2
I would not recommend your current approach (using a while loop to wait until the timer is finished), as that will put all the code and actions in the object event on hold until that while function is done.
You should also look up the difference between a button 'press', and a button 'pressed'.
When it's press, it'll do the action as long as the button is hold.
when it's pressed, it'll only do the action once when the button is pressed and released.
I found a way to swiftly do it by creating a timer thanks to a while statement, yes they exist; even though it's not written in the game maker manual, which is a relief but also a pain to deduce how it works in there sometimes.
while (timer > 0 && timer < numberofframesyouwanttheactiontogoonfor)
{
timer++
break;
}

Use KinematicBody2D as RigidBody2D

Hello, I'm new on Godot (I'm French, that's why my English is not perfect)
I'm trying to create a game (top down) where the principle is the same as a Sumo fight, take out your opponent outside a circle. The problem that I met is that if I use KinematicBody2D the characters don't push each other which is the base of the game, I saw then that it could be possible with RigidBody2D but I can't find any way on internet to make it move like this : https://docs.godotengine.org/fr/stable/tutorials/2d/2d_movement.html#rotation-movement . I then searched if it was possible to push a KinematicBody2D with another KinematicBody2D (so that it can be pushed) but I also couldn't find any way.
So I'm stuck here, and my question is if this is possible and especially how I could do this?
Thanks for reading,
Noflare
I believe the issue here would be that you are not using collisions. The functions move_and_slide or move_and_collide would engage a Kinematic Body to move, and hit other bodies (including Kinematic Body).
However, as soon as you use either function you will realise they don't push each other in the way you need in the question.
From the docs (en, fr)
move_and_collide: The moving object will move and if there is a collider (any obstacle), it will stop immediately upon collision and return a KinematicCollision2D object.
move_and_slide: Takes further action compared to move_and_collide, the moving object will slide over the collider, treating it like a wall or a floor. Useful for platformer games.
In your use case, you have no choice but to control the collision yourself. You can get more info here on KinematicCollision2D here: (en, fr). This could be possibly how you do it:
var collision = player.move_and_collide(direction_vector)
if (!collision):
# No collision occurred
return
else:
# Collided with a wall or player
if (collision.collider == wall)
# if you keep track of wall object as a variable to identify it
# you can have the sumo just stop moving and not process anymore
return
else:
var opponent = collision.collider
# write game logic to move opponent and yourself
return

multinote instruments and chords

I am new in ableton live software. I would like to understand why for some instruments I can play several notes at the same time (and create chord progression) and for the others I can hear only one note of a chord.
For example, there are two guitars: 'Power Chords Guitar' and 'Please Rise For Jimi Guitar'. Both of them are basing on an operator. For the first one I am able to press several buttons on midi keyboard and hear a sound, for the second I can hear only one note of a chord.
I was trying to compare operator options, but I was unable to find the setting which causes this multinote/mononote functionality.
Thank you very much for your help.
J
Ableton's Operator consists of 4 monophonic oscillators. Depending on a preset, it can be setup to play polyphony. It seems that the Glide function is responsible for that effect. Make sure you have at least 2 oscillators (the more the more poly) with Glide "on" set.
Check out Ableton's webpage for reference on how to use its instruments.

Motion tracking goes way off

So I've been messing around with Project Tango, and noticed that if I turn on a motion tracking app, and leave the device on a table(blocking all cameras), the motion tracking goes off in crazy directions and makes incredibly wrong predictions on where I'm going (I'm not even moving, but the device thinks I'm going 10 meters to the right). I'm wondering if their is some exception that can be thrown or some warning or api call I can call to stop this from happening.
if you block all the camera, there is not features camera can capture.
so motion tracking may be in two stages:
1. No moving,
2. drifting to Hawaii.
either ways may happen.
If you did block the fisheye camera, yes, this is expected.
For API, There is a way to handle it.
Please check life cycle for motiontracking concept
For example for C/C++ :
https://developers.google.com/project-tango/apis/c/c-motion-tracking
if API detected pose_data as TANGO_POSE_INVALID, the motion tracking system can be reinitialized in two ways. If config_enable_auto_recovery was set to true, the system will immediately enter the TANGO_POSE_INITIALIZING state. It will use the last valid pose as the starting point after recovery. If config_enable_auto_recovery was set to false, the system will essentially pause and always return poses as TANGO_POSE_INVALID until TangoService_resetMotionTracking() is called. Unlike auto recovery, this will also reset the starting point after recovery back to the origin.
Also you can add Handling Adverse Situations with UX-Framework to your app.
check the link:
https://developers.google.com/project-tango/ux/ux-framework-exceptions
The last solution is by write the function handle driftting by measuring velocity of pose_data and call TangoService_resetMotionTracking() and so on.
I run a filter on the intake that tries not to let obviously ridiculous pose changes through, and I believe no reported points whose texel is white nor any pose where the entire texture is in near shouting distance of black

How do I generate a waypoint map in a 2D platformer without expensive jump simulations?

I'm working on a game (using Game Maker: Studio Professional v1.99.355) that needs to have both user-modifiable level geometry and AI pathfinding based on platformer physics. Because of this, I need a way to dynamically figure out which platforms can be reached from which other platforms in order to build a node graph I can feed to A*.
My current approach is, more or less, this:
For each platform consider each other platform in the level.
For each of those platforms, if it is obviously unreachable (due to being higher than the maximum jump height, for example) do not form a link and move on to next platform.
If a link seems possible, place an ai_character instance on the starting platform and (within the current step event) simulate a jump attempt.
3.a Repeat this jump attempt for each possible starting position on the starting platform.
If this attempt is successful, record the data necessary to replicate it in real time and move on to the next platform.
If not, do not form a link.
Repeat for all platforms.
This approach works, more or less, and produces a link structure that when visualised looks like this:
linked platforms (Hyperlink because no rep.)
In this example the mostly-concealed pink ghost in the lower right corner is trying to reach the black and white box. The light blue rectangles are just there to highlight where recognised platforms are, the actual platforms are the rows of grey boxes. Link lines are green at the origin and red at the destination.
The huge, glaring problem with this approach is that for a level of only 17 platforms (as shown above) it takes over a second to generate the node graph. The reason for this is obvious, the yellow text in the screen centre shows us how long it took to build the graph: over 24,000(!) simulated frames, each with attendant collision checks against every block - I literally just run the character's step event in a while loop so everything it would normally do to handle platformer movement in a frame it now does 24,000 times.
This is, clearly, unacceptable. If it scales this badly at a mere 17 platforms then it'll be a joke at the hundreds I need to support. Heck, at this geometric time cost it might take years.
In an effort to speed things up, I've focused on the other important debugging number, the tests counter: 239. If I simply tried every possible combination of starting and destination platforms, I would need to run 17 * 16 = 272 tests. By figuring out various ways to predict whether a jump is impossible I have managed to lower the number of expensive tests run by a whopping 33 (12%!). However the more exceptions and special cases I add to the code the more convinced I am that the actual problem is in the jump simulation code, which brings me at long last to my question:
How would you determine, with complete reliability, whether it is possible for a character to jump from one platform to another, preferably without needing to simulate the whole jump?
My specific platform physics:
Jumps are fixed height, unless you hit a ceiling.
Horizontal movement has no acceleration or inertia.
Horizontal air control is allowed.
Further info:
I found this video, which describes a similar problem but which doesn't provide a good solution. This is literally the only resource I've found.
You could limit the amount of comparisons by only comparing nearby platforms. I would probably only check the horizontal distance between platforms, and if it is wider than the longest jump possible, then don't bother checking for a link between those two. But you might have done this since you checked for the max height of a jump.
I glanced at the video and it gave me an idea. Instead of looking at all platforms to find which jumps are impossible, what if you did the opposite? Try placing an AI character on all platforms and see which other platforms they can reach. That's certainly easier to implement if your enemies can't change direction in midair though. Oh well, brainstorming is the key to finding something.
Several ideas you could try out:
Limit the amount of comparisons you need to make by using a spatial data structure, like a quad tree. This would allow you to severely limit how many platforms you're even trying to check. This is mostly the same as what you're currently doing, but a bit more generic.
Try to pre-compute some jump trajectories ahead of time. This will not catch all use cases that you have - as you allow for full horizontal control - but might allow you to catch some common cases more quickly
Consider some kind of walkability grid instead of a link generation scheme. When geometry is modified, compute which parts of the level are walkable and which are not, with some resolution (something similar to the dimensions of your agent might be good starting point). You could also filter them with a height, so that grid tiles that are higher than your jump height, and you can't drop from a higher place on to them, are marked as unwalkable. Then, when you compute your pathfinding, as part of your pathfinding step you can compute when you start a jump, if a path is actually executable ('start a jump, I can go vertically no more than 5 tiles, and after the peak of the jump, i always fall down vertically with some speed).

Resources