I was recently assigned to create a siple game using the Corona SDK. The main pillar of the game would be a simple event: the user should put a ball in a basket, and I should be able to handle this event.
Here is a picture for better understanding:
I successfully managed to create the collision shape for the basket, but i have trouble with the collision of the inside of this basket. My first thought was the following:
create a new shape
size and position it to fit the "belly" of this basket
add it to the physics-world, and listen to the collision.
With hybrid drawing it looks like this:
But there is a problem: if i add this shape to the physics, it wouldn't let the ball fall into the, basket, it will handle this shape as a solid object as well.
So my question is: How could I get this custom object to collide, without blocking the
ball to fall through it? I have read a lots of forum post with similar questions but none of them got a proper answer. There must be a way to do this in an elegant way.
And one note: Please don't suggest checking the collision manually, with rectangle intersection, because in this simple case it would work, but later I may need to change the shape of the basket, and then it will be useless!
Box2D has a thing called "sensor".
You just set the internal collision one to be a sensor, and it will do exactly what you want :)
Just do:
MyInternalCollisionObject.isSensor = true
Related
My Problem is maybe a rather simple one. I want to build up a simple Model of a Flettner Rotor. So it is just a fixed SupportStructure with a Motor/Revolute (fixedBearing) on top, that spins a hollow cylinder around it. At the Bottom there should be a loose fit, which i am not able to model...
On the attached pictures you can see the built up model and an animation of it. It is possible to simulate it without the "RevolutePlanarLoopConstraint".
I have to connect both structures again to model a second loose bearing. Because you have to create a loop, i tried all joints and constraints like "RevolutePlanarloppConstraint". In my opinion it should work ;)
No matter in what combination, i wasnt able to built up this connection. There is always the same error...(picture)
I cannot use the Rotor1D or something else, because i want to replace the bodys with existing discretized beam models later.
I think it is a typical problem of a locational/loose bearing combination, and i hope one of you has maybe a simple solution for it:)
Sadly i dont have the reputation to post images...
Kind regards
Paul
I'm asking a question for a school project. I am trying to play a video in a loop and change its speed according to the distance from the Kinect 1414. When you are far the video plays at normal speed, which then increases as you get closer.
I tried in different ways but sometimes either the video doesn't loop or it doesn't show, I can only hear the audio. Other solutions don't let me change the speed of the video. Do you know any way to have the distance of a person affect the video?
Thanks.
Stack Overflow isn't designed for general "how do I do this" type questions like this. It's for specific "I tried X, expected Y, but got Z instead" type questions. But I'll try to help in a general sense.
You need to break your problem down into smaller pieces and then take on those pieces one at a time. For example, can you start with a very basic sketch that just displays the distance from the Kinect? Don't worry about the video yet, just display the distance on the screen.
Separately from that, can you create another sketch that just shows a video playing in a loop? Work your way up from there: can you make it so its speed is based on a hard-coded value? How about on a value like mouseX?
Get those two basic sketches working perfectly by themselves before you start thinking about combining them. Then if you get stuck on one of those steps, you can post a MCVE along with a specific question (in a new question post), and we'll go from there. Good luck.
SceneKit
Is there a way to get notified when dynamicBody is in resting State ?
I want to remove dynamicBody when it finished to fall to the ground and stopped moving completely - I presume that I will have quite large amount of those so I would like to use something event based rather than looping through all the bodies and checking their velocities ?
You could use Key-Value Observation on the isResting property. See Is key-value observation (KVO) available in Swift?.
Or you could use the SCNPhysicsContact and SCNPhysicsContactDelegate to detect collisions with the floor, and use that to trigger a check for velocity.
I have a pretty basic but specific question that I can't seem to find the answer for. I've got a Blueprint containing a static Cube mesh, BlockAll collision without Physics Simulation enabled, for one of my levels. The entire floor is padded with them.
I've got it scripted up to have an effect once the player hits it, but it only seems to work when the player jumps on it. When he walks on it directly, the OnHit event does not trigger. Does this sound at all familiar? Am I missing a basic step here?
Got somewhat answered here by Erasio;
https://answers.unrealengine.com/questions/375634/static-mesh-doesnt-trigger-onhit.html
I'm creating a cricket manager stats game. I need to create a ball-by-ball simulation of the game. The game/ball outcome will be influenced by player stats and other external factors like weather or chosen tactics.
I've been reading around that most of the games can be implemented as a state machine, which sounds appealing to me, but because I'm a newbie at cricket I'm failing to envision this game as a state machine.
Should the Ball be a state machine or the match or the player or all 3. I'm also not sure how will i orchestrate this state machines (through events).
I'm also having hard time identifying the States and transitions. Any help would be greatly appreciated.
So here's what I understand from your question - Your cricket manager game will simulate a match ball by ball depending on player stats (bowler's skill/experience, batsman's skill/exp, fielding/wicketkeeping stats, so on...) and other related variables. From my understanding this will be more of an algorithmic engine rather than a visual representation of a cricket game.
Now answering your question, first of all, I don't believe you're looking at FSMs the right way. An FSM is a piece of code designed such that at any point in it's lifetime, it is in one of many possible states of execution. Each state can and usually has (that's the point of it) a different update routine. Also, each state can transition to another state upon predefined triggers/events. What you need to understand is that states implement different behaviour for the same entity.
Now, "most of the games can be implemented as a state machine" - Not "a" state machine but rather a whole nest of state machines. Several manager classes in a game, the renderer, gameplay objects, menu systems, more or less everything works off a state machine of its own. Imagine a game character, say a boxer, for the purpose of this example. Some states you'll find in the 'CBoxer'(?) class will be 'Blocking', 'TakingHit', 'Dodge', RightUpper', 'LeftHook' and so on.
Keep in mind though, that FSMs are more of a design construct - a way to envision the solution to the problem at hand. You don't HAVE to necessarily use them. You could make a complete game without a state machine(I think :) ). But FSMs make your code design really intuitive and straightforward, and it's frankly difficult to not find one in any decent sized project.
I suggest you take a look at some code samples of FSMs at work. Once you get the idea behind it, you'll find yourself using them everywhere :)
As a first step you should go through the rules of cricket and your model for the ball outcome to summarise how previous balls affect a given ball.
Then identify what you need to keep track of, and whether it is convenient to use a state machine to represent it. For example, statistics are usually not very convenient to keep track of as FSMs.
With that information in mind, you should be able to build a model. Information you need to keep track of might be either state machines or an internal value of a particular state. The interactions between balls will dictate the transitions and the events circulating from one machine to another.