Jump to content
  • Advertisement

jb-dev

Member
  • Content count

    81
  • Joined

  • Last visited

Community Reputation

50 Neutral

1 Follower

About jb-dev

  • Rank
    Member

Personal Information

  • Role
    3D Artist
    Game Designer
    Programmer
  • Interests
    Art
    Audio
    Design
    Programming

Social

  • Twitter
    MiiMii1205
  • Github
    MiiMii1205
  • Steam
    MiiMii1205

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Last week didn't have any particular theme, although it still was a busy one... Statuses First off, all statuses now have effect textures. these are really abstract, but nice to look at. (From left to right: Bleeding, Burning, Damned, Frenzied, Frozen, Knocked Out, Poisoned, Paralyzed and Stunned) Also, I've perfected statuses effects on enemies. Now their current status is a lot more obvious. A nice status icon is displayed over their head to help identify that status. The Diner Secondly, I've added a new room: the diner. The idea of it is quite simple: the diner offers food for the player to eat. The room itself is modelled after classic 50s diners with a jukebox and checkered patterns all over the place. There's even a nice neon sign that is truly aesthetic. The lighting is still a WIP, but the models themselves are pretty much done. There might be some details to add here and there, though... The exterior also needs some work. I was thinking of giving it a huge diner sign, but for now, there's nothing fancy... Crystals Lastly, I've given the player the ability to switch their active crystals. For those who didn't know, crystals are run-persistent collectables that can give the player the opportunity to take shortcuts that gives fame and fortune to whoever chooses to take them. A GUI element is displayed at the bottom of the screen. Within it, there are 3 crystal counters for each type of crystals. When the player switches their active crystal, the element rotates around to display the right counter at the right time. There's even a nice animation for it. I've only worked on this yesterday, so it still has rough edges here and there. Also, there's no discernable way to identify the active type of crystal on the GUI element alone as of yet... There are some icons that could be ready, but I want to try to put those icons in a custom font file. This way, I can use Unity's dynamic text display functionality to have scalable graphics. One of the drawbacks of this is that only monochrome icons can be used... Minor updates Modified the bank so that it spawns with a back wall Fixed bugs with MonoBehaviours scripts presets Fixed a whole lot of bugs with the map generator. Turns out that when the player was extremely lucky, they could remain trapped in the stating room because all other rooms would become secret rooms. Added a limit on how many secrets tunnel rooms can be spawned Added a ceiling to most room obstacles such as locked doors and cracked walls so that the lighting won't look weird anymore. Added back walls to special rooms. Thus, the design of those rooms will be applied continuously rather than abruptly end. Changed the tri-colour decal shader to add emission (mainly used with the diner's neon sign) This week Now that the diner is done, I can go ahead and continue the implementation of even more rooms. Last time I've talked about status-themed rooms, but turns out that there are a lot of other more important rooms to be added beforehand. I will be adding these up progressively... Now that the player knows their current active crystal type and their remaining amount, I can also add rooms dealing with those. I could also try to spawn pickable crystals, but right now rooms seem to be more important than crystals: they add more opportunities and varies the gameplay a lot. And finally, another possibility is to actually create these custom font files I've previously talked about, although it's not that important... Before I forget! Last week I've forgotten to mention that I've also tried to compose some music for the game. Here's a preview: ohok.mp4
  2. Last week I've worked on implementing statuses in the game. To put it simply, statuses negatively affect entities. Things like poisoning or bleeding, for example, will continuously dish out damage for a specific amount of time. Statuses Here's a list of some statuses and their effects. Keep in mind that statuses times aren't final and will eventually change depending on the impact of their effects... Poisoned This status is self-explanatory. It will damage the entity for about 20 seconds. The damage amount will increase linearly through time. Burning In essence, the entity is burning. Not dissimilar to being poisoned, the burning status also damages the entity for 20 seconds. The difference here is that the damage will increase using a reciprocal function. Bleeding The entity is bleeding heavily. Again, that status is like the previous two. The difference here is that the damage will increase logarithmically. Frozen The enemy is frozen solid. It can still move but at a reduced speed. Can also attack, but at a slower rate than usual. It will go away after 20 seconds. Damned The enemy is cursed. For 20 seconds, the entity will be extremely unlucky. Any luck tests will fail regardless of the entity's current luck. Paralysed The entity is paralyzed. For 20 seconds, the entity can't move. Frenzy The entity is caught up in a violent frenzy fits. If the entity isn't the player, then they will ignore the player and attack its friends. If the entity is the player, then the situation is reversed: every entity will attack the player. It lasts for 20 seconds. After then, the fits end. Here's a video of frenzied enemies fighting themselves: InAFrenzy.mp4 Stunned The entity is blinded and incapacitated. A big and blinding flash is produced. The affected entity retrains their mobility, but both vision and earing are temporarily lost. Knocked out The entity is knocked out. it can't move or see... A mix between paralyzed and stunned, except that everything will black out rather that light up. Statuses visual effects Each of these effects will have their own visuals to help to identify what type of effect is induced in who. If the effect is applied to the player, then a vignette effect is applied to the screen. This effect actually has a nice wavy effect among other things... Here's a video of it: wavy.mp4 When inflicted by the frozen status, the player will also see ice crystals forming on their screen, just to be fancy. If otherwise an AI is given a status, then the same pattern will be applied to it. The pattern is also screen aligned, making it really abstract. New Relics and Activated items Because statuses are now fully implemented in the game, there's now even more relics and activated items. These are directly related to statuses and give the player unique capacities like to those as well. Relics There are 4 new relics. These are all related to statuses in one way or another... Hot dreams This is an abstract representation of a sunset. It's actually quite cliché in 80s aesthetics... This relic also does billboarding. There are just some shapes that don't translate well in 3D... With this, the player is able to set entities on fire (thus giving the burning status) to attacked enemies. These attack can be direct (like a hit) or not (like a laser beam). As long as it originated from the player, it's all right. Here are its modifiers: -5% ATK +5% AGL Ice drop This is an ancient artifact resembling a raindrop. While holding it, any attack received or given will result in the other party to receive the frozen status. Here are its modifiers: +10% DEF -5% ATK Crystal Cola This is a clear cola. It's supposed to represent a Crystal Pepsi. This relic gives the Purifier capacity. In essence, it can make the player resistant to status changes. Here are its modifiers: +10% LCK -5% ATK Crystal Tea A nice tea beverage. It's a reference to Arizona green tea. It has the Purifier capacity and also speeds up attacks. Here are its modifiers: -25% ATK +25% AGL Activated Items There's only one new activated item: the Lipstick. Lipstick Alignment: Future Funk This is a lipstick. A red one in fact. While holding it, the player will experience a small growth... When activated, the item will make any hostile entities in a 25m radius receive the frenzy status. Here are its modifiers: -20% LCK Minor changes There weren't a whole lot of other changes. But the AI was considerably changed to include status effect in their behaviour (ex: stunned enemies can't spot the player or frenzied enemies will attack other enemies)... Next week There's still a lot of work on status effects. For example, not all statuses have patterns, and there's also more effects to be added and tweaked here an there. If there's anything new, it could be better props or even more specials rooms... After all, now that statuses are in, there's a lot of things that can be implemented.
  3. jb-dev

    Vaporwave Roguelite

  4. Last week I've worked on two things: Foods and Activated Items. I can safely say that my goal was achieved, and even surpassed. I've managed to add three working Activated Items and a whopping 9 foods in total. So let's dive right into it. Focus system crash course Before we dive right into activated items, we first have to know about the focus system. The focus system is like the classes or specializations system in most RPGs. Except that the focus system is actually quicker and is overall much more simpler than traditional RPG class system. (Because it's in a roguelike game and permadeath exists) In essence, each time the player uses those items, then its focus will shift through three poles: Vaporwave (Rogue/Assasins), Future Funk (Marksmen) and Hardvapor (Brawler). Having a certain focus can results in additional bonuses in certain stats, and can even give weapons and other items different type of bonuses and capacities. As of right now, no actual bonuses are implemented. This is because the focus system is primarily linked to the player's equipment... These aren't in the game just yet... Activated items If you played The Binding of Isaac, then you may be familiar with this concept. The idea is to have an item that can have an effect when manually triggered. Activated items work just like this: they are items that the player can activate. Most of the time, these give additional abilities to the player, like becoming temporarily invisible. Activated items can also have relic-like capacities that apply as long as the item is held, and can also have modifiers. Items can also have a focus alignment. Right now, only three of these are functional in the game. The Cellphone Alignment: Vaporwave This is an old piece of junk. It's supposed to represent an old Motorola brick phone. With this phone, the player is able to set up a one-way teleportation trip. First, the player needs to set up an exit point by activating it. This will create a weird sphere of spatial distortion Afterwards, when the player activates the item once more, they will be instantly teleported to it. Useful when you're in a huge level and want to get back to a specific room like a mall after getting more dosh. Here are it's modifiers: -5% ATK -10% HP Survival Gear Alignment: Hardvapor This activated item is supposed to represent a survival backpack. With this item, the player can sacrifice its health for foods. Here are its modifiers: -20% AGL -10% HP This Alignment: None This is this or at least my interpretation of it. In my head, an object always was a big red specular sphere. Maybe it's because I started making games with Game Maker? Perhaps... With This, the player can reroll all items in a 25 meters radius for 10$. Here are the modifiers: +25% LCK -10% HP Foods Foods are like temporary relics. They sometimes have capacities like relics and also have modifiers that are usually out of this world. When the player eats foods then a countdown is initiated. When the countdown is finished, all modifier and capacities given to the player are removed. Right now every food lasts for about 5 seconds. This will be individually tweaked based on things like modifiers and capacities... Here's a list of foods in the game: Pineapple This is a simple pineapple. Nothing special here Here are the modifiers: -10% LCK +25% ATK +50% DEF -10 AGL Banana A normal banana. Here are the modifiers: +75% LCK +68% DEF +50% AGL Lime A normal lime, cut in half. Here are the modifiers: +10% LCK +25% ATK +75% AGL -10% HP Pineaburger A burger made of a slice of pineapple. There's also a lettuce leave thrown in there for good measure. Here are the modifiers: -10% LCK +25% ATK +50 % DEF -10% AGL Double Deluxe A plain waffle topped with whipped cream and glazed with some kind of syrup (claimed to be raspberry, but sure doesn't taste like it) Here are the modifiers: +75% LCK +10% ATK -25% DEF +10% AGL +5% HP Instant Ramen A normal instant ramen bowl. chopstick included. Here are the modifiers: +50% ATK +50% AGL -25% HP Bento box A somehow 80s bento box, with crazy shapes, lines and colours. Comes with chopsticks. Here are the modifiers: +25% LCK +10% DEF -10% AGL +75% HP Toast Sandwich A somehow plain looking sandwich. It appears to have a heavily buttered toast in the middle. This is one of the food that can give you a capacity. When eaten, it gives the capacity to do a double jump. Here are the modifiers: -10% LCK +25% DEF -50% AGL -5% HP Minor updates There are now proper debug tools, such as spawning folders and so, making the testing phase so much quicker Resolved some bugs with mall inventory not being properly chosen Finally added relic/foods/equipment/weapon spawning to folders items. This means that the player can finally get good loot from folders. Fixed an infrequent bug that gives wrong orientation to some rooms (i.e. some breakable wall used to spawn perpendicular to the rooms) Added a bunch of things to add effects like 2d drop shadows and outline rendering Next week Next week I planned to add statuses to the game. Statuses like poisoned of stunned. There's already a list of statues that was previously prepared. Now it's just a matter of implementing those. Otherwise, if I have the time I'm probably going to continue the implementations of items/capacities... I also realized that while testing things out I just forget I'm testing and I just play the game (even though there's only one unfinishable level) I genuinely had fun... I wish this feeling will get bigger as this is developed.
  5. In my previous update, I've said that the next step would be to integrate relics in the game. I'm proud to say that I've managed to implements some of the planned relics. What are Relics? If you played The Binding of Isaac, you may recall it's Passive Collectibles. Relics are the equivalent in this game. In other words, Relics are run-scoped upgrade the player either find or (if they're lucky) buys in malls. These give stats percentage bonus (i.e. +25% bonus in attack) and also give the player special capacities. What are Capacities? Capacities are passive (i.e. not explicit, or don't need special inputs) abilities the player gain. For example, one capacity could be the capacity to shoot laser beams at each attack. There's a science to it, though. They need considerable balance tweaks here and there just to make sure the game won't break with these capacities. Some capacities are linked to relics, and others not. For example, a capacity can be linked to a specific Item or even Foods. Right now, there are no items or Food in the game, so we'll talk about those in due time... Stats crash course Before we continue with the relics, we first need to understand stats. Stats are exactly what you think they are: just like in most RPG, they quantify the skills of a given entity. In the game, there are 5 base stats : Chance (or Luck if you're fancy): This stats dictates the probability of a player to have good things happen to them (e.x. good loots spawns after an enemy is killed or a lot of special rooms and tunnels are spawned). It also dictates your chance of doing a critical hit (when so, the total damage output are 50% stronger) Attack: it's self-explanatory. This simply gives how much damage is given at each hit Defence: Also self-explanatory. This simply says how much damage is subtracted from an attack Agility: This stats dictates how fast your character goes. there might be more in the future, but for now, it only affects this Vitality (or Health if you're fancy): This stat simply represents your maximal health. These make CADAV. I don't know if it's clever enough, but it's catchy. (Not as good as SPECIAL, but good enough) For each stat, there is two different type of bonus/malus. These are a unitary bonus (or simply bonuses) and a percentage bonus (or modifiers). Bonuses usually come with pieces of equipment (things like armour and/or weapons), while modifiers are usually applied with capacities as a counterweight. Relics List Here's a small list of relics that are fully functional as of today: Laser Gem The laser gem is a relic resembling an abstract transparent cube with an opaque core. When the player picks up that relic, it gives them the ability to fire penetrating laser beams that deal damage to enemies when the player attacks. When the laser collides with anything but entities (like enemies) it will be reflected. This can be a quite powerful tool to quickly dispatch large amounts of enemies. The beam itself last for about 10 seconds, and only 3 beams can be fired at a time. Here are the modifiers: -10% of Attack +5% of Luck Modern Computing This relic is also abstract, but it's nevertheless more meaningful than the previous relic. Both its name and its model references something really vaporwave. But I'll let you figure it out. When the player grabs this relic, a combo system is activated: for every enemy killed, drops that cames from defeated enemies will linearly increase in number. Of course, being a combo system, if the player is hit then the combo is reset. Here are the modifiers: -5% of Luck -4% of Attack Credit Card The credit card is a credit card. (I didn't know what you expected) With this cool relic, the player can actually purchase anything they want anywhere even if they lack the money for it. Buying an item without the needed money creates a debt in the player's funds. After each 10$ of debt, a random amount of negative modifiers are applied to the player's stats. When the player pays off their debts then these nerfs are progressively removed. Because of this special capacity, no base modifiers are applied when this relic is grabbed. DOUBLE-VISION This relic is rather abstract. It's actually a pair of eyes. When the player grabs this relic, every loot that are consumables (i.e bombs, keys or money) are doubled. Here are the modifiers: -5% of Attack -10% of Luck +5% of Agility Extension Cord This relic is simply a North American electric extension cord. There are two capacities attached to this relic. The first one simply makes the range of your attacks bigger. Its just actually the game resizing your weapons... Nothing special here. The second one is more a nerf than anything else: It slows down your attack speed by half. Here are the modifiers: -25% of Attack -25% of Agility Boxed Copy This relic is a Software box. It's supposed to mimic the Windows 9x boxes. With this relic, on the first successful hit by the player to an enemy, the latter has a chance to get "Boxed". When being "boxed", enemies are transformed into a similar box like the relic itself. However, that box is able to be opened by the player. It then spawns a random amount of consumables. It essentially one hit enemies if your lucky and gives you loot too. This only works on the first hit: subsequential hits won't work. Here are the modifiers: -25% of Attack Atk-booster 2000 This relic is a computer chip, presumably a CPU. It simply increases your attack speed by half. Here are the modifiers: -25% of Attack +10% of Agility Watch Out! This relic is a simple watch. With this one, you gain the ability to backstab other enemies. (not unlike the TF2 backstab) This means that if you hit their back they get one hit. In essence, this works by using the same algorithm that my vision field Here are the modifiers: -40% of Attack -25% of Health +5 of Agility Minor Updates Items that are in malls, along with relics and pieces of equipment, now rests on pedestals. These get removed when the item is picked up or otherwise get removed There's now a key collectible that can spawn with any type of loot. Picking these up simply increments the player's total amount of keys The Big Mall (the generic one) now has a chance to spawn a buyable relic in its inventory Fixed many bugs with a whole lot of things Thrown items now properly trigger AIs: they will look at the player that has thrown said projectiles rather than the projectile itself What's next? This week I'm planning to add more capacities and maybe add either Foods or Items in the game. Same goal as before: at least one Food or Item. Just to be clear: Items are like The Binding Of Isaac's Activated Collectibles except that they also change the player's stat and may also add passive capacities while the item is being held. As for food, think of relics, but temporary (a bit like Minecraft's potions). Here comes another big week I guess...
  6. I've decided to change the frequency of these updates: most of the times, I just do some minor updates and graphical tweaks here and there. Therefore, if I do these updates weekly, then I'll have a lot more content to write about. So, yeah... Last week, I've been working on adding many different types of rooms in the level. You may or may not know that I use BPS trees to generate a level, and previously, only 5 types of rooms spawned in a level: starting rooms, ending rooms, normal rooms, tunnel rooms and Malls. It was very static and not flexible, so I've changed it to make it more dynamic. Malls Variations First, I've added two different variations for Malls: Blood Malls and Clothes Malls. These were originally planned and already built. Big Malls These are your typical type of Malls. You can find everything here. This is where, for example, you'll find hearts, keys and/or bombs. They were already in the game, but now they're more specialized (or generalized in this case) Blood Malls The Blood Malls specialized in bloody activities. (meaning that you'll mostly find a selection of weapons here) Clothes Malls The Clothes Malls are specialized in clothes, which in our case are actually pieces of equipment the player can have New Rooms Aside from these new type of malls, I've also added 3 new types of rooms. These rooms, however, are guarded by a locked door: the player must use a key to enter. In order to unlock a locked door, the player just needs to touch it. If the player has enough keys, then a key is used and the locked door disappears. There's also an event that triggers that can do things when the player unlocks the door (like revealing hidden models and what not) The Gym The gym is a room resembling some of these outside gyms you can see in some places. The player can use up to tree gym equipment to get a permanent stats bonus to a randomly selected stat. The prices of usages of these gym equipment doubles after each use. (i.e. if using one piece is 10$, then after buying it the others will cost 20$ and so on) I've planned that NPC would use non-interactive gym workstations for decoration, but it's not really important as of right now... The Bank The bank is not fully functional at the moment, but it still spawns. The idea is to give the player a way to store money persistently throughout runs. The player can then withdraw money (with a certain transaction fee) from that bank. That means that you can effectively get previously deposited money back when you'll need it the most. The Landfill The landfill gives you the opportunity to gain back previously thrown away pieces of equipment. Basically, the game stores the last three thrown away pieces of equipment. When the rooms spawn, it simply displays you those pieces of equipment. you can then pick them up for free. This, however, comes with a caveat: pieces of equipment that will be switched from a previously thrown away pieces of equipment won't reappear in another landfill. Also, once the landfill despawns, the items in that landfill will be discarded. (Think of it as a last chance opportunity) There aren't any props at the moment, but it's fully functional. Minor Tweaks Aside from that, there are also some minor tweaks: Bombs now damage the player if the latter is within its blast radius; Player jumps are now more precise: letting go of the jump button early makes a smaller jump than if it was held down longer; Ground detection (that was previously done with raycasting) now uses Unity's CharacterController.isGrounded property; When the player is hurt, a knockback is applied to him; The strength of said knockback is actually the total amount of damage the player took. Coins and money items now emit particles to help the player localize those important items; They're now keys (left) and bombs (right) counters in the HUD; The key one still needs a specific icon, but it's fully functional; There were many shader optimizations and adjustments: Many shaders were merged together and are now sharing most code; I've also changed the shaders so that we can use GPU instancing for most props, I also now use MaterialPropertyBlock for things like wetness; Also, now the palette texture and its palette index are now global variables, this effectively means that I only need to set these values once and everything else follows; A small "Sales" sign is placed in front of most types of malls. This sign has a random orientation and position each time it's spawned. ; Props that obstruct a passage are removed from the room; This way no prop can obstruct the room so that the player cannot exit it. Some rooms now spawn ferns instead of palm trees; Lianas also have different configurations based on which prop spawns. Next week Over the next week, I've planned to integrate the first relic. Relics are items that give the player capacities and stats boosts. It's common to have something similar in most roguelite and roguelike games. That type of thing needs to have a good abstraction in order to work: there are many different types of capacities that affect the player in radically different ways. There's a lot of work ahead. But I'm confident it'll be easy. Just need to get in the groove.
  7. During the past days, lots of shaders were updated and other visual things did too. Firstly, I've added lights effects when the crystals get shattered. There's also a burst of particle emanating from the broken crystal on impact. Also, enemies now leave a ragdoll corpse behind when they die. I love some of the poses those ragdolls make. On another note, I've toyed around with corpse removal and got captivated by the shrinking effect it created. It can sometimes be off-putting, but I'm still captivated. I've also added a nice VHS-like effect from layering two VHS shader together; namely "more AVdistortion" and "VHS pause effect". I've already ported the former and it's already active and the latter was just a matter of porting GLSL shaders to HLSL. No biggie. I did change the code a bit to make the white noises move through time. And there's nothing like trigonometry to help us with that fixed4 frag (v2f i) : SV_Target { fixed4 col = fixed4(0, 0, 0, 0); // get position to sample fixed2 samplePosition = i.vertex.xy / _ScreenParams.xy; float whiteNoise = 9999.0; // Jitter each line left and right samplePosition.x = samplePosition.x + (((rand(float2(_UnscaledTime, i.vertex.y))-0.5)/64.0) * _EffectStrength ); // Jitter the whole picture up and down samplePosition.y = samplePosition.y + (((rand(float2(_UnscaledTime, _UnscaledTime))-0.5)/32.0) * _EffectStrength ); // Slightly add color noise to each line col += (fixed4(-0.5, -0.5, -0.5 , -0.5)+fixed4(rand(float2(i.vertex.y,_UnscaledTime)),rand(float2(i.vertex.y,_UnscaledTime+1.0)),rand(float2(i.vertex.y,_UnscaledTime+2.0)),0))*0.1; // Either sample the texture, or just make the pixel white (to get the staticy-bit at the bottom) whiteNoise = rand(float2(floor(samplePosition.y*80.0),floor(samplePosition.x*50.0))+float2(_UnscaledTime,0)); float t = sin(_UnscaledTime / 2); if (whiteNoise > 11.5-30.0*(samplePosition.y + t) || whiteNoise < 1.5-5.0*(samplePosition.y + t) ) { // Sample the texture. col = lerp(tex2D(_MainTex ,samplePosition) , col + tex2D(_MainTex ,samplePosition), _EffectStrength); } else { // Use white. (I'm adding here so the color noise still applies) col = lerp(tex2D(_MainTex ,samplePosition), fixed4(1, 1, 1,1), _EffectStrength); } return col; } It's nice to have HLSL code, but a video is better:
  8. After thinking about it, I've could have gone with deferred decals, but I thought i didn't need that right now: most of my geometries are flat at the moment...
  9. Today was kind of a slow day too. I've haven't got a lot of sleep lately (thanks little hamster wheel in my head) But at last, I was still able to add (and also fix) some graphical components here and there. In short, I've made the first and last rooms of the level more distinct from every other room. For example, I've added a room flow on these rooms to properly align props and, in the case of the starting room. the spawning rotation. I've also added a little decal-like plane that tells the player what to do (take it as a little tutorial, if you may) The important thing is that this decal is, not unlike my palette shader, dynamic in terms of colours. What I've done is quite simple: I've mapped each channel of a texture to a specific colour. Here's the original texture: After inputting this texture in my shader, it was just a matter of interpolating values and saturating them: Shader "Custom/TriColorMaps" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _Glossiness ("Smoothness", Range(0,1)) = 0.5 _Metallic ("Metallic", Range(0,1)) = 0.0 _RedMappedColor ("Mapped color (Red channel)", Color) = (1, 0, 0, 1) _GreenMappedColor ("Mapped color (Green channel)", Color) = (0, 1, 0, 1) _BlueMappedColor ("Mapped color (Blue channel)", Color) = (0, 0, 1, 1) } SubShader { Tags { "RenderType"="Transparent" } LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows vertex:vert decal:blend // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D _MainTex; struct Input { float2 uv_MainTex; }; half _Glossiness; half _Metallic; fixed4 _RedMappedColor; fixed4 _GreenMappedColor; fixed4 _BlueMappedColor; void vert (inout appdata_full v) { v.vertex.y += v.normal.y * 0.0125; } // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. // #pragma instancing_options assumeuniformscaling UNITY_INSTANCING_BUFFER_START(Props) // put more per-instance properties here UNITY_INSTANCING_BUFFER_END(Props) void surf (Input IN, inout SurfaceOutputStandard o) { // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex); c.rgb = saturate((lerp(fixed4(0, 0, 0, 0), _RedMappedColor, c.r) + lerp(fixed4(0, 0, 0, 0), _GreenMappedColor, c.g) + lerp(fixed4(0, 0, 0, 0), _BlueMappedColor, c.b))).rgb; o.Albedo = c.rgb; // Metallic and smoothness come from slider variables o.Metallic = _Metallic; o.Smoothness = _Glossiness; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" } Also, note that I've changed the vertices of the model. I needed a way to eliminate the Z-Fighting and just thought of offsetting the vertices by their normals. In conclusion, It's nothing really special, really. But I'm still working hard on this. EDIT: After a little bit of searching, I've seen that you can give a Z-buffer offset in those Unity shaders by using the Offset state. So I've then tried to change a bit my previous shader to use that functionality rather than just offsetting the vertices: SubShader { Tags { "RenderType"="Opaque" "Queue"="Geometry+1" "ForceNoShadowCasting"="True" } LOD 200 Offset -1, -1 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Lambert decal:blend // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D _MainTex; struct Input { float2 uv_MainTex; }; fixed4 _RedMappedColor; fixed4 _GreenMappedColor; fixed4 _BlueMappedColor; // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. // #pragma instancing_options assumeuniformscaling UNITY_INSTANCING_BUFFER_START(Props) // put more per-instance properties here UNITY_INSTANCING_BUFFER_END(Props) void surf (Input IN, inout SurfaceOutput o) { // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex); c.rgb = saturate((lerp(fixed4(0, 0, 0, 0), _RedMappedColor, c.r) + lerp(fixed4(0, 0, 0, 0), _GreenMappedColor, c.g) + lerp(fixed4(0, 0, 0, 0), _BlueMappedColor, c.b))).rgb; o.Albedo = c.rgb; // We keep the alpha: it's supposed to be a decal o.Alpha = c.a; } ENDCG }
  10. Today, I've worked on level exits. When the player arrived at the last room before, nothing awaited him. He was stuck for eternity on the same level. Kinda boring, actually... But today this is no more! Now a big Ethernet port awaits the player at the end of the level. He just needs to jump in it to clear the level. I've had to create two new shaders: one that can fade the screen to black according to the player's y coordinates. I've also needed to modify my main shader to add a new parameter that can create a gradient from the usual colours to pitch black. This way, I can simulate a bottomless pit.
  11. Today, I've fixed some bugs with the crystal throwing algorithm. Basically, crystals will be used by the player to get to those alternative paths I've mentioned in my BPS tree entry. There'll be at least 3 type of crystals : Fire, Water and Life. Each will be thrown to eliminate obstacles at the entry point of each alternatives paths. I've also planned them to be persistent throughout runs. This means that the amount of crystals are linked to a save file rather than a run. So if the player didn't used their crystal during the run, then they'll have the opportunity to use them in another one. As you can see, each type of crystal has a particular particle effect attached to them. I've tried to simulate how each type of elements would react. So the fire crystal particles behaves like flames, life one like fireflies and water one like drops of water. I still have to give them a distinctive shape... For now, I've used the default particle sprite provided with Unity. Also, after a crystal hit something, it'll generate other type of particles. These particle will move accordingly to the impact force. So, to recap, I've been working on particles for the past days... Kinda slow, but I think it's worth it...
  12. In the previous iteration of our game, we decided to use an actual cone as a way to make an AI "see". This implementation was hazardous, and it quickly became one of the hardest things to implement. We eventually were able to code it all, but the results were really static and not really realistic. Because of the reboot, I took the time to actually identify what constraint one's vision has. The visual field First of all, a cone isn't really the best in therm of collision checking. It required a special collider and could have potentially been a bottleneck in the future when multiple AI would roam the level. In actuality, the visual field can be represented as a 3D piece of a sphere (or more like a sector of a sphere). So we're gonna need to use a sphere in the new version. It's cleaner and more efficient that way. Here's how I've done it: foreach (Collider otherCollider in Physics.OverlapSphere(m_head.transform.position, m_visionDistance / 2, ~LayerMask.GetMask("Entity", "Ignore Raycast"), QueryTriggerInteraction.Ignore)) { // Do your things here } Pretty simple, really... Afterwards (not unlike our previous endeavour), we can just do a simple ray cast to see if the AI's vision is obstructed: // Do a raycast RaycastHit hit; if (Physics.Raycast(m_head.position, (otherPosition - m_head.position).normalized, out hit, m_visionDistance, ~LayerMask.GetMask("Entity", "Ignore Raycast"), QueryTriggerInteraction.Ignore) && hit.collider == otherCollider) { // We can see the other without any obstacles } But with that came another problem: if we use a sphere as a visual field, then the AI can surely see behind his back. Enters the cross product. Vectorial cross product The cross product is a vectorial operation that is quite useful. Here's the actual operation that takes place: \(\mathbf{c} = \mathbf{a} \times \mathbf{b} = ( \mathbf{a}_{y}\mathbf{b}_{z} -\mathbf{a}_{z}\mathbf{b}_{y}, \mathbf{a}_{z}\mathbf{b}_{x} -\mathbf{a}_{x}\mathbf{b}_{z}, \mathbf{a}_{x}\mathbf{b}_{y} -\mathbf{a}_{y}\mathbf{b}_{x} )\) This actually makes a third vector. This third vector is said to be "orthogonal" to the two others. This is a visual representation of that vector: As you can see, this is pretty cool. It looks like the translation gizmo of many 3D editors. But this operation is more useful than creating 3D gizmos. It can actually help us in our objective. Interesting Properties One of the most interesting properties of the cross product is actually its magnitude. Depending on the angle between our two a and b vectors, the magnitude of the resulting vector changes. Here's a nice visualization of it: As you can see, this property can be useful for many things... Including determining the position of a third vector compared to two other vectors. But, however, there's a catch: the order of our a and b vector matters. We need to make sure that we don't make a mistake, as this can easily induce many bugs in our code. The funnel algorithm In one of my articles, I've actually explained how pathfinding kinda works. I've said that the navigational mesh algorithm is actually an amalgamation of different algorithms. One of these algorithms is the Funnel algorithm, with which we actually do the string pulling. When the Funnel algorithm is launched, we basically do a variation of the cross product operation in order to find if a certain point lay inside a given triangle described by a left and right apexes. This is particularly useful, as we can actually apply a nice string pulling on the identified path. Here's the actual code: public static float FunnelCross2D(Vector3 tip, Vector3 vertexA, Vector3 vertexB) { return (vertexB.x - tip.x) * (vertexA.z - tip.z) - (vertexA.x - tip.x) * (vertexB.z - tip.z); } With this function, we get a float. The float in question (or more particularly its sign) can indicate whether the tip is to the left or to the right of the line described by vertexA and vertexB. (As long as the order of those vectors are counterclockwise, otherwise, the sign is inverted) Application Now, with that FunelCross2D function, we can actually attack our problem head-on. With the function, we can essentially tell whether or not a given point is behind or in front of an AI. Here's how I've managed to do it: if ( FunnelCross2D((otherTransform.position - m_head.position).normalized, m_head.right, -m_head.right) > 0 ) { // otherTransform is in front of us } Because this is Unity, we have access to directional vectors for each Transform objects. This is useful because we can then plug these vectors into our FunnelCross2D function and voilà: we now have a way to tell if another entity is behind or in front of our AI. But wait, there's more! Limit the visual angle Most people are aware that our visual field has a limited viewing angle. It happens that, for humans, the viewing angle is about 114°. The problem is that, right now, our AI viewing angle is actually 180°. Not really realistic if you ask me. Thankfully, we have our trusty FunnelCross2D function to help with that. Let's take another look at the nice cross product animation from before: If you noticed, the magnitude is actually cyclic in its property: when the angle between a and b is 90°, then the magnitude of the resulting vector of the cross product is literally 1. The closet the angle gets to 180° or 0°, the closest our magnitude get to 0. This means that for a given magnitude (except for 1), there are actually 2 possible a and b vector configurations. So, we can then try to find the actual magnitude of the cross given a certain angle. Afterwards, we can store the result in memory. m_visionCrossLimit = FunnelCross2D(new Vector3(Mathf.Cos((Mathf.PI / 2) - (m_visionAngle / 2)), 0, Mathf.Sin((Mathf.PI / 2) - (m_visionAngle / 2))).normalized, m_head.right, -m_head.right); Now we can just go back to our if and change some things: if ( FunnelCross2D((otherTransform.position - m_head.position).normalized, m_head.right, -m_head.right) > m_visionCrossLimit ) { // otherTransform is in our visual field } Then we did it! the AI only reacts to enemies in their visual field. Conclusion In conclusion, you can see how I've managed to simulate a 3D visual field using the trustworthy cross product. But the fun doesn't end there! We can apply this to many different situations. For example, I've implemented the same thing but in order to limit neck rotations. it's just like previously, but with another variable and some other fancy codes and what not... The cross product is indeed a valuable tool in the game developer's toolset. No doubt about it.
  13. @ethancodes does the original ball get its velocity changed? If not, maybe you could try debugging it with breakpoints. If you don't know how, Unity has a tutorial on this matter. For example, you could just put breakpoints before and after the velocity change and see if your balls' velocity changes at all.
  14. Today was kind of a slow day: I had many things to do, so development was kind of light... Nevertheless, I've still managed to do something... I've added a way to highlight items through emission (not unlike how we did it previously) and make enemies blink when they get hurt. It wasn't really hard: because this is Unity, the surface shader got us covered. It was just one simple line of code. #ifdef IS_EMISSIVE o.Emission = lerp(fixed3(0, 0, 0), _EmissionColor.rgb, _EmissionRatio); #endif
  15. Have you tried with a ForceMode2D parameter too? (Like, right after the force) If so, then maybe there's somewhere else during the frame that just removes your previously set velocity... I do kind of the same thing (except in 3D). I instantiate rigidbodies and add a force to them...
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!