New answers tagged

0

Set their position to be almost perfect - account for floating point precision. So if your player is 8 units tall, and your platform is at (5,6), and you land on the platform, then: When you see an imminent collision, set the player's y position to 6+8+0.01 6 is the y position of the platform. 8 is the player size offset. 0.01 is the floating point ...


0

Your code is a little bit confuse. Also, I tried cloning it and the project is incomplete, so I can't import it. If I understood your code, you're using box2d bodies but you're not setting the sprite position taking in consideration the Box2d units. Box2d works with meters, so you have to convert pixels to meters and take in consideration the fact that box2d ...


1

One way to do this would be to clamp (limit) the x and y values of the camera to your width and height of the game. It may look something like this: Clamp method: public int clamp(int var, int max, int min) { if(var > min) { if(var < max) { return var; } else return max; } else return min; /* * var = your variable ...


2

A newbie's answer. Suppose the orange marked place is the position for your enemy to jump, you make a trigger on the orange x mark of the object on the prefab and tell the enemy ai to jump when the ai hits the trigger. Simple Answer.


0

Ok so I have //Vertical collision if(!place_meeting(x,y+sign(vsp),obj_wall)) { while(!place_meeting(x,y+sign(vsp),obj_wall)) { y+=sign(vsp); } vsp=0; } y += vsp; but I should have //Vertical collision if(!place_meeting(x,y+sign(vsp),obj_wall)) { while(!place_meeting(x,y+vsp,obj_wall)) { y+=sign(vsp); } ...


4

I understand you are dealing with both box obstacles and gaps. The way it was described, I can see three possible situations. Correct me if the game is designed differently. With the first, there are no obstacles before the gap, at least no obstacles that the player can jump atop. In this case, you would need only a fix max width for the gap. In the ...


3

Do it at the generator level: Always generate your level using a selection of passable gaps / obstacles section prefabs. If two successive sections are not passable mark them as such so the generator does not put both in succession and/or adds some space between them. These sections will also instruct the AIs on how to clear the obstacles.


1

It sounds like you want to implement your own physics instead of using what's built in. Fortunately, you don't have do any kind of parabolic calculation when jumping (unless you want to project the path of the character or something like that). Instead, you let physics run its course which will naturally create parabolic shapes. Here is some example code for ...



Top 50 recent answers are included