Box2d Raycast C ++. Always getting fake? (trying to verify if the player is grounded)

I am trying to add Box2d to my C ++ / SFML platform game. I have my ground tiles with a b2staticBody. And the player's character is b2_dynamicBody.

My usual method of checking if the player is grounded is Raycast directly from the center of the sprite to just below foot level. (NOTE: yes I notice that SFML is y-down).

For now, I just want the raycast to come true if it hits something. But it always returns false. I watch the player land on the ground and I can walk on the ground and fall (i.e. the built-in box2d collision works)

Here is my code (I'm new to using Box2d in c ++, sorry if it's wrong. There aren't many good examples online)

void guy::update() {
bool bGrounded = false;
b2RayCastOutput output;
b2RayCastInput input;
input.p1 = bodyPtr->GetPosition();
input.p2 = bodyPtr->GetPosition() + b2Vec2(0, 1.f * Constants::PPU); 
input.maxFraction = 1.0f;
b2Fixture* fixture = bodyPtr->GetFixtureList();
std::cout << "p1: " << input.p1.x << " , " << input.p1.y << " / p2: " << input.p2.x << " , " << input.p2.y << std::endl;
std::cout << "sprite pos: " << sprite.getPosition().x << " , " << sprite.getPosition().y << std::endl;
if (fixture->RayCast(&output, input, 0))
    bGrounded = true;
    bGrounded = false;
std::cout << "isGrounded: " << bGrounded << std::endl;

The console outputs appear to be fine (that is, p1 and p2 are where they expected them to be), but the bool always returns 0.

Of course, I am very open to an improved jump function. Eventually I want to be able to add the ability to hold the jump button for some time to get a bigger jump. But the only way I can start is by checking if the player touches the ground first.

unreal 4 – How can I make a particle emitter (actor) fade according to the proximity of the player?

Essentially everything is in the title: I have a cylindrical effect made of a particle emitter, but it could be any object with a shader, and I want it to fade closer and closer (it appears when I approach)

I would like to do this with plans.

I imagine that I am modulating the opacity, but where is the best place to do this? On the object? or the plane of the player?

2d – Platform collision detection problem – player hitting the sides

I have problems with collision detection. I am trying to make a simple platformer, but when the player falls or moves too fast, he sometimes detects the wrong collision side. I am understanding the side of the collision by checking the distance between the player and the sides of a block that are exposed to the player. I also tried to detect the collision of one axis at a time, but this problem still occurs.

enter the description of the image here

blockCollision: function(block) {
        if(this.x + this.width > block.x && this.x < block.x + block.width && this.y + this.height > block.y && this.y < block.y + block.height) {
            let distanceLeft = Math.abs(this.x + this.width - block.x)
            let distanceRight = Math.abs(this.x - (block.x + block.width))
            let distanceTop = Math.abs(this.y + this.height - block.y)
            let distanceBottom = Math.abs(this.y - (block.y + block.height))

            if(distanceLeft < distanceTop && distanceLeft < distanceBottom && !block.collisionSides.includes('L')){
                this.velX = 0
                this.x = block.x - this.width
            if(distanceRight < distanceTop && distanceRight < distanceBottom && !block.collisionSides.includes('R')){
                this.velX = 0
                this.x = block.x + block.width
            if(distanceTop < distanceLeft && distanceTop < distanceRight && !block.collisionSides.includes('T')){
                this.jumping = false
                this.velY = 0
                this.y = block.y - this.height 
            if(distanceBottom < distanceLeft && distanceBottom < distanceRight && !block.collisionSides.includes('B')){
                this.velY = 0
                this.y = block.y + block.height

            if(distanceLeft == distanceTop && !block.collisionSides.includes('LT')){
                this.x = block.x - this.width
                this.y = block.y - this.height
            if(distanceLeft == distanceBottom && !block.collisionSides.includes('LB')){
                this.x = block.x - this.width 
                this.y = block.y + block.height
            if(distanceRight == distanceTop && !block.collisionSides.includes('RT')){
                this.x = block.x + block.width
                this.y = block.y - this.height
            if(distanceRight == distanceBottom && !block.collisionSides.includes('RB')){
                this.x = block.x + block.width 
                this.y = block.y + block.height


Unity: how to get players to see only one specific player but not others?

Good Morning.
I am developing an educational game that is not multiplayer. However, I would like to add a function that allows the teacher to enter the game and that all students can see it, but no student can see the other students.
Is there a way to do that?
I appreciate your time and guidance.

dnd 5e – Management of the new player "Murder Hobos"

So I'm running an LMoP game for a group of new players, and everyone is having a great time. However, we are all very new: it is the first time I have run a PW Campaign as DM (I only had a few unique games before), but I have a lot of player experience, and the Players are new. to that too.

We are in two sessions, and it has been quickly established that a player is a fairly complete Hobo Killer. While the player is new, and all the enemies have been one-shot murders (all the goblins), (and let's be honest, we've all been guilty of some bloodthirsty journey); This player has left the background a bit.

The player executes a pregenerated Halfling Rogue * with short Sword and Short Bow, and so far he has managed to knock down almost half of the enemies he has encountered, without anyone's help. They have a taste for blood and is affecting their game.

It is true that they are a true neutral criminal, with "loyalty to my friends, without ideals. Everyone else can take a trip on the Styx River." Ideal of character. Is could being a "My Guy Syndrome" situation (however, I doubt it, none of the players have really gotten into the character, they have simply made decisions based on their abilities); But it is becoming a problem, independently.

Not only are do not avoiding combat (the only reason they have not been eliminated in one fell swoop is due to bad dice rolls), instead of charging melee without thinking twice; They have suggested that each and every one of the characters they interact with should be killed. The reasons are "because it is easier". A kind of "No muss; no fuss" approach.

This has included:

  • An elf, who survived an initial fight to provide information about the Goblin hiding place.
  • The central NPC of the plot, captive by the goblins.
  • The same Goblin who was captured before, after being tied, and already admitted to having "changed his customs"; He had also declared that he had been unconscious because he was tied upside down for several hours.
  • Other PCs (only a first thought about whether PvP was allowed or not, and I have stated that PvP is not allowed)

What I have tried so far is:

  • He reminded the player that he is small, cunning, with little HP. They stand out in stealth and combat, they should do everything possible to sneak the attack as much as possible, if the situation requires it.
  • He interpreted the conversation between players as part of the PC conversations; So the NPCs are aware from side to side:

    Rogue: "We should kill him. He is obviously working for the Goblins."

    NPC: "I can hear you." He reaches a sword lying on the ground. He is clearly injured and needs to rest after being tormented and tortured by the goblins, but obviously he is worried about his own safety for his frivolity at the thought of killing him.

  • He even interpreted the stage where the captured and unconscious Goblin was killed; which led a group to explode with protest against the player (not me, who made the decision), which led to a vote to confiscate the Rogue's weapons, only to return them when necessary (go to dangerous territory or at the beginning of a fight) I will allow a free action to return the weapons at the beginning of a fight).

That's where he left it until the next session. Is there any way I can / should handle this better?

* These are the pregenerated characters we are using, we are using the Starter Set.

Combat: I need help dealing with what I think is "My Guy" and how can I reach a midpoint with this player

Now, I feel that this needs some context. The place where I am playing is in this sub-reddit called exploring fiction. It is a small and pleasant place where people can publish the worlds they have built and play with those who visit their world. The rules are as follows.

1. We are here to have fun and develop our worlds and characters, to be civilized.

2. Do not control other people's characters.

3.Not erotic, unless the entire publication is NSFW (eg (Scene) Jim & # 39; s Exotic Whorehouse).

4. Follow the rules of the OP, if they say your character is too dominated for the scene, then dim it.

5.Original characters and settings only. No fanfiction or established characters of any kind.

So, obviously, I feel that rule 4 is breaking a bit. It is quite inherent since the sub-reddit lacks strict rules and is purely narrative. This has led to conflicts of power with those with whom I had RP in the past. In the past, it allowed them to have their fantasy power and end that, but the more I do it, the more I think I need to address it.

Now, the guy I'm playing the role with is super cool and it's relatively new, so I'm not trying to be a jerk with all this. Here is the conversation we are having on the subject so far.

Part 1 of the conversation

and part 2

Age system: Can a player use Fortune to reduce a dice roll in The Expanse RPG?

In The Expanse RPG, a player can spend Fortune Points (FP) to improve a test by changing a dice value equal to the amount of FP spent.

Can a player also use this mechanic to decrease a value thrown away?

For example, when the player has a target number of 10 and rolls 2, 5, 6 (regardless of skill points), can you spend 2 FP to change the 5 to 2, thus earning acrobatics points (SP) while the test is still successful?

I am a little worried that players can (ab) use this rule too much to achieve stunts with a low cost of FP, which could also give "free" FP when using Adrenalin.

How to embed YouTube videos as an audio player

I tried this tutorial to embed YouTube videos as an audio player. But your demo does not work on that site. I tried it on Android and Ubuntu Chrome. Any solution available?

GM techniques: the player has trouble imagining the situation in the game

What this could be:

This is a good distinction to make, but I think the problem is minor because the player cannot imagine the situation in the game, but the player is drawing dramatically different inferences from the situation, different enough from his that you cannot Effectively plan around them, different enough from the players who find it (involuntarily) chaotic, and different enough from yours (again) that they can be harmful assets.

Here is why I think that:

  • He knows there is fire around. He caused it. It is part of his character's flaws, so he clearly imagines an environment that lacks something his character wants, fire, which he then creates. But the inference he is not drawing is that it is visible and will attract the monster.

  • He knows that the monster is too dangerous to fight, so he is also imagining that part of the environment correctly. But the inference that he is not drawing is that aerial night hunters have very good vision to detect movement.

Is could just be simple ignorance on the part of the player. You are in a better position to know, but I am a city boy and I can easily imagine a GM waiting for me to know something about woodwork (say) that I would simply sail directly over my head. That could Being part of the general fallacy of "We have to do something! Running is something! Run for it !!!!"(Everyone dies. Oh, shame).

There could be many things in this general neighborhood that I will summarize as "blind spots."

What i have seen:

I see things like this once in a while and, hell, I've been that guy once or twice. I suspect, but I can't prove, that most people have been that type once or twice; nobody knows everything. So I'm not sure that two sessions are enough to know if this guy is really unusual in his failure to make good inferences, or if he simply has bad luck and is exactly in the wrong situation for him, personally, in the initial scenario.

When I see things like this, about half of them tend to be related to social and social violence ("What do you mean I can't throw a fireball at the thief who got into the crowded market?" Uhh … why will you kill a dozen other people? And maybe you'll burn the whole city? ") And the rest are random things about which a player has really wrong ideas … or at least very different from the DJ.

What I do:

In general, what I do (and I have seen others do) is simply tell the player that his character knows that it is a very bad idea based on any skill or statistic that he has that seems applicable … and that I hope they hear that advice, learn from him and carry it forward in the future. Even if all they learn is: "Wow, I really don't know anything about how aerial night predators operate; I should check with the other players," that can be a victory.

As a GM, you can do this, be the voice of common sense specific to the character's game world. Set up a situation where you feel you are cheating if it happens too often.

How well does it work? It is mixed, honestly. Fireball launchers generally appear quite quickly when they realize that it is not a videogame from the 1980s that will restore everyone's attitudes as soon as they are out of sight. Blind spot characters generally only have to learn to move through blind spots, which is … challenging.

What I advise you to do:

As above, and talk to your player. No confrontations, but try to find out why he was doing those things. And asking is almost always more effective than trying to solve it because, let's face it, you still haven't been able to solve it.

What will not work:

If I am right, and this is just a blind spot or lack of knowledge, then Session 0 will not work. Sessions 0 have the undeclared assumptions that everyone is making informed statements about their preferences and promises, and that they are able to deliver.

But if there really is a blind spot of knowledge, those assumptions are not true, and the player can promise, in good faith, to try to imagine the game world. But it will continue to fail if it lacks fundamentally knowledge about some parts.

vampire the masquerade – How can I tell a player to stop something without looking like I'm restricting it too much?

Board role games are games and everyone who plays is supposed to be fun. If this player's actions are causing you to have less fun than you were having before, you need to talk to them. If this type of game bothers you, you must say so. It's not about judging because all kinds of things that a person feels comfortable with may not be. Be clear as to what exactly bothers you so there is no confusion.

Dial again

The first option to really solve the problem is to ask them to redial it. All this requires is that they change the amount of time they spend on descriptions. Instead of "I kiss you here and here and (…)" you can say "I kiss you with kisses, I do all those romantic things".

Lines / Veils

(If you don't know what lines and veils they are, you can find an earlier answer here)

This is something similar to dialing again but it means even less talking. You can draw a line and say "I will not represent these romantic scenes with you, it is uncomfortable for me." If your player is your friend, they will respect the line and not cross it. If you feel more comfortable with Some romance can turn it into a veil that says something like "When the romance begins, make a persuasion check (or whatever VtM equivalent). (assuming a high number): We fade to black and you and your partner have a good time. "

The solution I hope is not used

If your player disrespects you and crosses your lines or ignores the veil or tries to pass the comfort point for you, he is not your friend. They are actively doing something that they to know You don't like it and that's unacceptable. Remove them from the group. They have shown that they do not care enough for you to respect your limits and that you should not bear that.


Just talk about what is and what is not comfortable for both of you. You should be able to reach a resolution that doesn't seem to take away aspects of your character and that everyone can have as much fun as possible.