• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

1564 Excellent

About Ovicior

  • Rank

Personal Information

  • Interests
  1. Goodbye!

    I'll never forget those times you hit me with warning points. Also, that one time you told me a lot about swing dancing. RIP Josh. I wish you could see how much I've grown.
  2. Thanks! This presentation is useful. I'll definitely keep it in mind when designing my system.
  3. You can either take 2-4 years and learn to program to the point you can make an engine, or you can just use Unity.
  4. I plan on having close to 100 weapons. Many will feature some sort of unique effect. I don't quite completely understand how "TargetSelector, an AudioVisualAttackRepresentation, and a TargetStatusApplier" would all work together. A target selector doesn't seem too necessary considering only the lightning sword will chain as of now. Having something to create the proper "streak" or "smear" animation is good, and having something apply the effect for each weapon seems pretty good as well. Would the 'TargetStatusApplier' also be used for something immediate, like stealing an enemy's health? Or would it only be for longer-term statuses like burning/frozen.
  5. An attack is just really whenever the player left clicks, at which point a prefab with a collider that checks for enemies inside itself is instantiated at whatever angle the player is facing. The visual representation is a slash effect. I'd like to think that I'd instantiate a prefab for something like an explosion and have some sort of lightning prefab that can take gameobjects as parameters to chain between. My apologies, but I still don't quite understand how I'd use composition in this way. Wouldn't it be easier to have a normal Weapon component that handles most calculations, with unique Components for each weapon that use the Weapon component to do their behavior? I'm not too familiar with writing quality code, I've mostly been trying to learn how to make stuff work over the past four years.
  6. Hey, So I'm currently working on a rogue-like top-down game that features melee combat. Getting basic weapon stats like power, weight, and range is not a problem. I am, however, having a problem with coming up with a flexible and dynamic system to allow me to quickly create unique effects for the weapons. I want to essentially create a sort of API that is called when appropriate and gives whatever information is necessary (For example, I could opt to use methods called OnPlayerHit() or IfPlayerBleeding() to implement behavior for each weapon). The issue is, I've never actually made a system as flexible as this. My current idea is to make a base abstract weapon class, and then have calls to all the methods when appropriate in there (OnPlayerHit() would be called whenever the player's health is subtracted from, for example). This would involve creating a sub-class for every weapon type and overriding each method to make sure the behavior works appropriately. This does not feel very efficient or clean at all. I was thinking of using interfaces to allow for the implementation of whatever "event" is needed (such as having an interface for OnPlayerAttack(), which would force the creation of a method that is called whenever the player attacks something). Here's a couple unique weapon ideas I have: Explosion sword: Create explosion in attack direction. Cold sword: Chance to freeze enemies when they are hit. Electric sword: On attack, electricity chains damage to nearby enemies. I'm basically trying to create a sort of API that'll allow me to easily inherit from a base weapon class and add additional behaviors somehow. One thing to know is that I'm on Unity, and swapping the weapon object's weapon component whenever the weapon changes is not at all a good idea. I need some way to contain all this varying data in one Unity component that can contain a Weapon field to hold all this data. Any ideas? I'm currently considering having a WeaponController class that can contain a Weapon class, which calls all the methods I use to create unique effects in the weapon (Such as OnPlayerAttack()) when appropriate.
  7. Hey, So I'm currently working on my first serious project. It's basically a rogue-like combat game that focuses on melee. I want the combat to be a blend of Crawl and Hyper Light Drifter. Anyways, I've been thinking about how to structure the game and cannot organize my ideas. Earlier, I wanted to create a health system for my player. Instead of just adding one to my 'PlayerController' however, I made a generic one with variables and methods that would allow for generic data storage. You'd specify a max health, and then use a method to inflict damage whenever needed. There was also a method to check if the entity died. I'm not sure if I can structure my whole project this way. So far my only other script is the one controlling player movement/attacks. I'm using Unity, so component-based design is a pretty big thing, Now I have to implement things like an XP system, a generic control for monster AI, and a template to define weapons. How should I approach all this code? How should I structure it? I took a look at this but still don't quite understand what it means. The entire time I've been making games, I've just been doing my thing. I found out with my last decently sized project that just writing code is not a good idea. Can someone introduce me to some game design/structure principles? Thanks.
  8. How to stay motivated?

    If your game is nearly done, maybe you should try and get a publisher to sponsor your project? Or maybe just sell the game itself? A bit of extra cash could really help you out.
  9. No, I am not using the rigidbody. I have custom gravity.     Thanks anyway :D
  10. Interestingly, the same ray is always changing when it shouldn't be. I changed the color and it still occurred. If the player falls from high enough, the rays doesn't seem to change its values. If the player lands close to the platform, the stray ray changes the value of the player by tiny amounts.   FIGURED IT OUT!     Turns out the gravity was accumulating and forcing the ray down. Just had to set gravity to 0 in the update function.
  11. Interestingly, the same ray is always changing when it shouldn't be. I changed the color and it still occurred. If the player falls from high enough, the rays doesn't seem to change its values. If the player lands close to the platform, the stray ray changes the value of the player by tiny amounts.
  12. They both start separated, with the square at the top. The gravity causes the square to land on the rectangle.
  13. I've been working on a 2D raycasting system, and have an odd glitch-like thing going on. When the rays fire off and collide with something, all of the rays work perfectly well except for one. This ray keeps pushing past the collider and, in turn, is constantly changing the player's y-values.     Can anyone see a fix?           Code: using UnityEngine; using System.Collections; [RequireComponent(typeof(BoxCollider2D))] public class Controller2D : MonoBehaviour { public LayerMask collisionMask; const float skinWidth = .015f; public int horizontalRayCount = 4; public int verticalRayCount = 4; float horizontalRaySpacing; float verticalRaySpacing; BoxCollider2D collider; RaycastOrigins raycastOrigins; void Start() { collider = GetComponent<BoxCollider2D>(); CalculateRaySpacing(); } public void Move(Vector3 velocity) { UpdateRaycastOrigins(); if (velocity.x != 0) { HorizontalCollisions(ref velocity); } if (velocity.y != 0) { VerticalCollisions(ref velocity); } transform.Translate(velocity); } void HorizontalCollisions(ref Vector3 velocity) { float directionX = Mathf.Sign(velocity.x); float rayLength = Mathf.Abs(velocity.x) + skinWidth; for (int i = 0; i < horizontalRayCount; i++) { Vector2 rayOrigin = (directionX == -1) ? raycastOrigins.bottomLeft : raycastOrigins.bottomRight; rayOrigin += Vector2.up * (horizontalRaySpacing * i); RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.right * directionX, rayLength, collisionMask); Debug.DrawRay(rayOrigin, Vector2.right * directionX * rayLength, Color.red); if (hit) { velocity.x = (hit.distance - skinWidth) * directionX; rayLength = hit.distance; } } } void VerticalCollisions(ref Vector3 velocity) { float directionY = Mathf.Sign(velocity.y); float rayLength = Mathf.Abs(velocity.y) + skinWidth; for (int i = 0; i < verticalRayCount; i++) { Vector2 rayOrigin = (directionY == -1) ? raycastOrigins.bottomLeft : raycastOrigins.topLeft; rayOrigin += Vector2.right * (verticalRaySpacing * i + velocity.x); RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.up * directionY, rayLength, collisionMask); Debug.DrawRay(rayOrigin, Vector2.up * directionY * rayLength, Color.red); if (hit) { velocity.y = (hit.distance - skinWidth) * directionY; rayLength = hit.distance; } } } void UpdateRaycastOrigins() { Bounds bounds = collider.bounds; bounds.Expand(skinWidth * -2); raycastOrigins.bottomLeft = new Vector2(bounds.min.x, bounds.min.y); raycastOrigins.bottomRight = new Vector2(bounds.max.x, bounds.min.y); raycastOrigins.topLeft = new Vector2(bounds.min.x, bounds.max.y); raycastOrigins.topRight = new Vector2(bounds.max.x, bounds.max.y); } void CalculateRaySpacing() { Bounds bounds = collider.bounds; bounds.Expand(skinWidth * -2); horizontalRayCount = Mathf.Clamp(horizontalRayCount, 2, int.MaxValue); verticalRayCount = Mathf.Clamp(verticalRayCount, 2, int.MaxValue); horizontalRaySpacing = bounds.size.y / (horizontalRayCount - 1); verticalRaySpacing = bounds.size.x / (verticalRayCount - 1); } struct RaycastOrigins { public Vector2 topLeft, topRight; public Vector2 bottomLeft, bottomRight; } }
  • Advertisement