Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by Stocke

  1. I looked into flow field pathfinding(after reading about steering behaviours) and it seems that it's mostly used for RTS games. I understand why, but wouldn't it also work for an action game with a single player character? It wouldn't be efficient, sure but it makes using steering behaviours easier to use. I could precalculate obstacles based on static colliders in the scene. And I can calculate the a vector towards the player for seek behaviours every frame. And reuse that for every enemy. I could then use inverse of the vectors for flee behaviours and make that avoid obstacles as well. If I wanted to steer a character perpendicular to the player, maybe I could rotate the vector in the field 90 degrees to obtain that? Of course this approach would not be valid for other behaviours. Like for pursuit you would need to calculate another vector field for the future position of the player. Unless there is some mathematical way to shift a flow field if the center(where the arrows converge) moves. I dunno how you would add local avoidance. Maybe keep track of enemy positions on another vector field and take that into consideration. A* is no doubt efficient and popular. But it does not work well if the agent has target velocities instead of target positions (like from using steering behaviours). And A* also has the problem of being too good(perfect paths => too robotic). Anyways, that's enough rambling from me. What do you think?
  2. Okay, so it didn't go as well as I hoped. Seek behavior works right off the bat. But you can't get flee behavior simply by using inverted vectors. Unless you don't care about getting stuck on corners. Still, Having easy access to player distance at all times is useful. I could query player distance for each tile and come up with a decent flee behavior by looking at nearby tiles. If that doesn't work then I'd need to have separate flow field arrays for everything and that'd suck.
  3. That bunny model sure is famous. It seems to pop everywhere. In any case, wasn't this covered in a GDC talk about PDEs? The method I came across didn't mention solving Differential Eqns at all. It simply ran a Djisksta/ BFS on the grid to calculate Distance to goal directly. Then just finds the direction from a tile where the distance from goal decreases. Ultimately, it still gives the gradient of sorts and agents can follow that direction after normalizing the vector. This was the link:https://simoncoenen.com/downloads/ai_paper.pdf No doubt it's efficient for an RTS game. But I'm talking about an action game where thre is one target(player) and a small amount of enemies. There's also an article about using it for particle simulation somewhere. I didn't think about using graph coloring algos to seperate entities at all before.
  4. I am trying to implement obstacle avoidance in unity as follows: I fire a series of parallel raycasts in the players moving direction, get the closest hit and then multiply hit.normal by steering force to get an avoidance vector.Then I use prioritization blending(have some max steering, I add obstacle avoidance steering first and then add seek steering towards target if I have not already reached max steering). The problem is that If the player is directly behind the wall then the seek direction and hit.normal(aka avoidance direction) is in opposite. Hit. normal seems to work if obstacle is far away but not much so if the obstacle is near. Am I supposed to calculate some other way?(normal component of hit.normal on my velocity vector maybe). And is it better to have cone raycasts instead of parallel ones?
  5. So assuming I am moving direction is transform.forward, and my perpendicular direction in my moving plane is transform.right, if I hit something, I need to move along or opposite transform.right. I then check the dot product with transform.right, If it's +ve I need to steer in the direction of tranform.right, if it's -ve I move in the opposite direction of transform.right. Is that correct?
  6. If the wall is to the right, target is also further right and wall is perpendicular to that direction I'd steer in that perpendicular direction. But How do I calculate that perpendicular direction in code?(My vector maths knowledge is a bit lacking)
  7. So I've been trying to use OOP where I need polymorphic behavior. I know that a lot of people have problems with it but it has worked out so far for me. I've tried to avoid using inheritance too much and tried to use composition to make bigger classes out of smaller ones. This is my situation. I have an attack class like abstract Class Attack{ abstract void execute(vector3 Dir); } And melee and ranged attack classes like class MeleeAttack{ override void execute(vector3 Dir){//do stuff} } class ProjectileAttack{ override void execute(vector3 Dir){//spawn stuff} } I need player specific attack behaviour so I have a player attack class that I use for the player. class PlayerAttack{//does not inherit attack since I need more parameters in execute Attack meleeOrRangedAttack; void execute(vector3 Dir, random params....){ //do meleeOrRangedAttack while obeying player rules dir = calculateDirTBasedOnInputOrSomething() meleeOrRangedAttack.execute(dir) } } And a different enemy Attack Class because enemies need to target a player. class EnemyAttack{ Player target; Attack meleeOrRangedAttack; override void execute(target){ //do meleeOrRangedAttack while targetting player dir = calculateDirToTarget() meleeOrRangedAttack(dir) } } This works well and I can reuse melee or ranged attacks both for players and enemies. But say I need a homing Attack for enemies. If I make it a subclass of attack then I can't just override execute(). I need some way to pass in a target. Is there a better way to structure this code while keeping composition(not writing separate enemy homing attack, player homing attack classes)?
  8. So according to Shaarigan's suggestion I delegated the targetting to TargettableAttack class that takes in a target and delegates to a attack class after calculating directions. For homing attacks I override that behavior by as necessary in a HomingTargettableAttack class.
  9. Having a separate target class will probably be an improvement. Previously I had the attack classes forget about direction altogether and rely on the facing direction (which was handled in player and enemy classes). But the problem is that some attacks might not work with a direction vector. An enemy might need to calculate projectile velocity based on player position and other attacks don't want to mess with direction. I can't just pass in a target vector for all cases. As for interfaces, Unity's serialization is broken . If I want assignable references in the editor, I need to use abstract classes. Otherwise I would have used interfaces. Clearly the code needs refactoring. I'm just not sure what direction it should go.
  10. I'm using unity and I always end up stopping my prototypes and one particular point-when I need to make the character controller. I can get away with setting the velocity directly in prototypes but it results in shitty game feel. If I use kinematic bodies then I can't do collision against enemies/walls. Physics interaction is another nightmare. And if you don't use kinematic rigid body then your player can be pushed by enemies in unrealistic ways. I'm might not be a coding expert but when it comes coding systems like damage or anything that isn't reliant on physics, I can do it without much of a problem. It's the physics related stuff that always gives me headaches. What's worse is that I can't even find any articles/tutorials on this aspect at all. I can ask questions on the unity subreddit and all I get is that it's highly game specific and I should I implement it myself. But where do I even start? Sorry for the rant. But this is an issue which must have been solved already. I'm sure that there are already assets for this but I can't afford them and I'm very much willing to do the work myself. Please, just tell me what I have to do.
  11. I... actually haven't tried the built-in character controller. Most of the posts I've come accross said that it caused a lot of issues for them and that they had implement their own controller in the end. Since I need some additional functionality (block pushing/ physics interaction) I mostly forgot about it. Thanks for mentioning it. It's a good starting point. I used Seblague's tutorial for a 2d platformer controller. I somehow never came accross his 3d controller tutorial. I'll give that one a good look. It's probably exactly what I need. Somehow help always comes from the place you least expect it. Thanks for the links Edit: Watched the video. It wasn't as thorough as I hoped but at least I know how to use the built-in character controller now.
  12. I do have problems with the animation portion. For example, I have no idea how to use root motion to move a character during an attack animation. But that is not the core of the problem. I never needed to deal with these animation issues because I end up quitting before implementing them. Any resources on that would be appreciated. But my main problem is making the platforming and movement feel smooth. Whenever I try to do that with rigidbodies things go wrong.
  13. I'm mostly asking about a general problem I have in the prototyping stage. I implement some of the mechanics. Then I feel that the movement sucks and I keep on changing movement code until I give up. If you are asking about the type of game I need a controller for, it's top down action hack and slash action game inspired by ys and hyper light drifter.
  14. Is it for tile based movement? I'm looking for a tutorial on character controller for an action game like bayonetta or Ys. So it should support some 3d platforming and combat animations.
  15. Brackeys does not have any tutorials on character controllers. I have not watched rm2k vids but they seem to quite old and focus on 2d tile based rpgs.
  16. I'm making a Pokémon clone in java as a student project. I'm using javafx for this. One of the features I need to work on is letting players play against each others. Only local multiplayer is required. Implement other words, the players can open up 2 instances of the game on the same pc and be able to play against each other. I'm done with implementing the logic necessary for the core game but I'm not sure about how to connect it to networking. In my game their is a trainer class. I have a loop for battle where I wait for commands ( an object) each trainer has chosen for the turn. For players, that's the move they selected. For the ai, it's a move chosen at random. The loop will end only when all trainers ( including player) has chosen commands and the turn will play out. I'm a novice at network programming but here's what I want to try. I know that you can send strings through sockets. The networked trainer class will work like the player trainer class but will wait for instructions from the other player's socket and convert them to commands which my game loop can use. Is this a viable approach?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!