22 Replies
JavaBot
JavaBot2mo ago
This post has been reserved for your question.
Hey @teyaaa12! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
dan1st
dan1st2mo ago
oh you are the same as https://stackoverflow.com/staging-ground/79321824 Are you sure you are only changing public void checkTile(Entity entity) to public void checkTile(Player entity) and this fixes the issue for players?
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
teyaaa12
teyaaa12OP2mo ago
Yes, changing public void checkTile(Entity entity) to public void checkTile(Player entity) solves the issue of the player colliding with tiles that have collision. However, this causes a problem when I add NPCs, as the method then requires reverting to public void checkTile(Entity entity). According to Ryisnow, the method should remain as public void checkTile(Entity entity) for it to work without errors. The issue with public void checkTile(Entity entity) is that when my player touches a tile with collision, the player becomes stuck. Additionally, if the player touches an NPC, both the player and the NPC become stuck.
JavaBot
JavaBot2mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
dan1st
dan1st2mo ago
oh so you have variables like screenx etc defined in Entity but also in Player why do you have them multiple times? This results in each Player having these variables twice and if you access them via Player, you can the Player ones but if you access them using Entity, you access the entity one so that's why you get different results
teyaaa12
teyaaa12OP2mo ago
Actually, their values are the same, so should I remove those variables from the Player class since it is a subclass of the Entity class?
dan1st
dan1st2mo ago
Are you sure the values are always the same? if you change the values in one of the classes and then access them from the other, you won't get the changed values this is exactly what causes the difference between checkTile(Player entity) and checkTile(Entity entity)
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
teyaaa12
teyaaa12OP2mo ago
The variables, such as solidarea, etc., represent the solid areas of the NPC and the player. I tried assigning them directly in my Entity class, but it does not resolve the issue of them getting stuck.
dan1st
dan1st2mo ago
?
teyaaa12
teyaaa12OP2mo ago
these are the issues
dan1st
dan1st2mo ago
Can you show your updated code that doesn't have duplicate variables?
dan1st
dan1st2mo ago
Did you remove the variables from Entity? oh nvm so screenx and screeny still exist multiple times
teyaaa12
teyaaa12OP2mo ago
Oh, sorry! So, I removed the declaration of public int screenX and screenY from my Player class. However, if you're referring to this: screenX = gp.screenWidth / 2 + (gp.tileSize / 2);
screenY = gp.screenHeight / 2 + (gp.tileSize / 2); It's only in the Player class, and it represents the player's position on the screen.
dan1st
dan1st2mo ago
it can still be done in the Player class if player refers to screenx, it would access the one from the entity class
teyaaa12
teyaaa12OP2mo ago
Yes, but I still have the same issue as in the video. I think I have a problem with my collision logic in the collision checker class.
dan1st
dan1st2mo ago
Do you know what a debugger is?
teyaaa12
teyaaa12OP2mo ago
yess
dan1st
dan1st2mo ago
Did you try setting a breakpoint in the collision logic to see what happens? like comparing it with your expectations
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?