So recently I've run into a slight problem. By slight I mean huge. I updated my drivers, as you do when there's a new update, and thought nothing else about it. When I next went to use Photoshop however, I experienced some unusual crashes. It started off when I tried to offset an image so that it would tile nicely, when just clicking offset crashed the program. So I restarted Photoshop, opened my image again, pressed offset, and it crashed. This happened once more before actually working.
Now that I had finally offset the image I wanted to edit it. Clicking the clone stamp tool crashed the program. It was very clear now that something was wrong so I headed in to university to ask my module leader what the issue could be. After explaining the situation he suggested it could be my GPU settings in Photoshop which when I got home and checked, I found out the latest updates had caused an error and would no longer allow my graphics card to interact with Photoshop.
I've tried to update the drivers and reset everything but so far there isn't any new developments. This means my only current solution is to do all of my texturing and artwork in the labs at my university, which isn't too bad an option considering the circumstances. The only other thing I can think of is completely uninstall then reinstall the program, which I'll try at some point soon.
Showing posts with label Unity. Show all posts
Showing posts with label Unity. Show all posts
Saturday, 26 December 2015
Thursday, 17 December 2015
Street Scene: Start of texturing
With all of the modelling pretty much sorted, it was about time to start texturing the scene. Like with the modelling, I wanted to start with the saloon as it's the focus point of my scene due to the ability to enter inside it. Being a western themed saloon I knew I was going to need a lot of wooden textures but they'd need to be different in shade,colour and appearance so everything didn't look the same and blend into one. Since I'm not a good artist in any sense of the word, to texture things I found images online, brought them into Photoshop and edited them enough so that they were like a different image that I could use.
![]() |
| Textured saloon |
I used contrasting textures for different areas of the saloon to make sure nothing clashed. I found a nice light board texture for the walls and used a darker wood texture for the furniture. To balance them even further I used a 'medium' texture (brightness between the two others) for the floor which is easy on the eyes. For the bar, stairs and landing I tried to use a texture that falls between the darker furniture and light walls, just to differentiate between the 3 sections.
Thursday, 10 December 2015
Street Scene: Audio & Story
For my game to be an actual game, I need the player to be told part of the story each time they trigger a point. This meant I needed to use Audacity for some voice and sound recording, which I was really looking forward too after how much I enjoyed doing the sound work in sessions. Before I could do any voice acting, I needed to come up with a story concept. My story is about a man who has lost everything and each story point is a memory. The character had a wife and 2 children, but lost all of them to accidents/illness. Following this, his farm is destroyed in a storm and he slips into depression. The ending is the player leaving town on a train from the train station.
I broke the story and points down into 6 sections:
1) Characters wedding day
2) Loss of characters wife
3) Loss of characters daughter
4) Loss of characters son
5) Farm is destroyed
6) Depression takes over the man
Once I had the story concept I could write a small script for each story point and detail what background affects/noises I wanted to accompany the voice acting.
I broke the story and points down into 6 sections:
1) Characters wedding day
2) Loss of characters wife
3) Loss of characters daughter
4) Loss of characters son
5) Farm is destroyed
6) Depression takes over the man
Once I had the story concept I could write a small script for each story point and detail what background affects/noises I wanted to accompany the voice acting.
Wednesday, 9 December 2015
AA shooter: Turrets and particles
With Richard absent this week, I worked on my AA project with the time given. I had a great idea in mind for my two player objects. Player one would have control of a machine gun turret that would fire lots of bullets very quickly, that would be controlled by aiming with the mouse and pressing LMB to fire. Player 2 would have a slower firing but harder hitting rocket launcher that used the Xbox 360 controller, with the right stick aiming and RT firing.
This contrast in weapons means that players will need to co-ordinate themselves and work together in order to win the game and not let the generator be destroyed. The faster firing player 1 needs to worry less about accuracy as they're firing a huge amount of bullets, but also deal less damage, whilst the rocket launcher is slower so needs to be more accurate and packs a much bigger punch as result.
Picture of turrets next to each other
Saturday, 5 December 2015
Street Scene: Day/Night & prototyping
Using what I was taught this week, I added a day/night cycle into my street scene. My game involves the player triggering a series of story points, so I came up with the idea to change the time of day each time they made progress by getting one of the points. I created a script and added it to the light which, when a point is triggered, rotates the entire object slightly on a single axis for a few seconds.
Unfortunately it's a little difficult to tell that the sun is moving unless you focus on the shadows on the ground, so if it's possible, adding some form of colour affect to the light at different stages would make it a more effective mechanic.
Unfortunately it's a little difficult to tell that the sun is moving unless you focus on the shadows on the ground, so if it's possible, adding some form of colour affect to the light at different stages would make it a more effective mechanic.
![]() |
| Code activated each time a point is triggered |
Monday, 30 November 2015
AA Shooting game: AI path-finding
For my game I'd like to have enemies that move up towards the player from cover to cover, before finally approaching the generator object and attacking it. In order to do this I need to use a navigation mesh and set points for the enemies to move between. I've created an array of points for the enemies to choose from, where they're limited to choosing from groups of four at a time. With the checkpoints set in rows of four, the enemies move from row to row advancing towards the players and generator.
rows of checkpoints
Unfortunately when all areas around the generator are occupied by enemies, even though I tell the next wave to wait until they're free, they try to occupy the spaces and cause a huge stack overload. Hence for now I've been forced to step back from the AI path-finding and had to stick with simply spawning them at set points around the players. I would like to play with this again when I have more time but for now, I have to give up on it.
rows of checkpoints
Unfortunately when all areas around the generator are occupied by enemies, even though I tell the next wave to wait until they're free, they try to occupy the spaces and cause a huge stack overload. Hence for now I've been forced to step back from the AI path-finding and had to stick with simply spawning them at set points around the players. I would like to play with this again when I have more time but for now, I have to give up on it.
Wednesday, 25 November 2015
Dark Arts 4: Statics, XML and Shaders
Static classes cannot be allocated, therefore there can be only one of them in which every method and variable must also be static. They can be used to load in files and store variables from them, such as settings, as well as wrap up methods you know will be needed in multiple places. Static classes are never deallocated which makes them really useful for keeping data around between scenes in Unity, like textures which would save on loading times.
XML was designed to be easily read by people as well as computers. All XML files must begin with the header of <?xml version="1.0" encoding="utf-8" ?> . From there you have to define an element which will be the name to call when needing the data inside (similar to a class). Inside that other elements can be defined which contain the precise data you require, in the form of a 'Key Value' pair e.g <player lives="3"/>. Every value is recorded as a string.
To use an XML file, you need to first parse it into Unity and then select the base element you want. Then you can walk through any children and use the key/value pairs as needed.
![]() |
| Static class to add and remove textures at will |
To use an XML file, you need to first parse it into Unity and then select the base element you want. Then you can walk through any children and use the key/value pairs as needed.
![]() |
| XML parsing class |
Monday, 23 November 2015
UI Card Game part 3
The final stage of the game, was the actual game mechanic itself. With the cards randomly shuffling upon starting the game, all I had to do was set the card backs to display as opposed to the front. I needed to set cards to flip upon being clicked and check if it matched the ID of the next card being flipped. If so then the cards needed to remain upright, otherwise flip them back.
To do this I needed a method in the card behaviour that passed the cards information to the game manager upon it being clicked. When two cards have been clicked and passed their information, a co-routine to compare the cards is started. If the two cards match, the tally for pairs needed to win increased, bringing the player one step closer to finishing and they then remain unclickable. If they don't match, both cards are flipped back and made clickable again.
The final thing to do was provide a win screen when the player matched every card. This was easily done by checking if the pair tally equaled 8 or not. If so then a delegate message is sent to display the win overlay image and I even added music to make it more of a celebration.
To do this I needed a method in the card behaviour that passed the cards information to the game manager upon it being clicked. When two cards have been clicked and passed their information, a co-routine to compare the cards is started. If the two cards match, the tally for pairs needed to win increased, bringing the player one step closer to finishing and they then remain unclickable. If they don't match, both cards are flipped back and made clickable again.
![]() |
| Card game partway through |
The final thing to do was provide a win screen when the player matched every card. This was easily done by checking if the pair tally equaled 8 or not. If so then a delegate message is sent to display the win overlay image and I even added music to make it more of a celebration.
![]() |
| Finished game with win display |
Saturday, 21 November 2015
Street Scene: Initial Street Building & Mind map
After the first week working on my street scene, I've planned out the layout and done some basic work an a few buildings. I decided on the five major buildings I was going to make and also wanted to add a few extra filler buildings to flesh out the scene. The smaller teal coloured buildings are the filler buildings that will have the same generic size and shape but a slightly different decorative roof board and decals. The far left building is going to become a church with a bell tower and stained glass windows. The light pink building will become a general store, the yellow one is the train station, deep purple will be a doctors and the big darker pink building is the saloon. I have plans for different props, to add more detail to the scene, such as barrels, crates, shacks and foliage.
I've imported the street model into Unity and edit it from there, so any changes I make in 3DS Max instantly appear for me to explore in-game. This way I can check scaling and the feel of things with ease as soon as I've made them. This also allows me to easily integrate my game mechanics with the street scene such as moving doors and interactive pieces when I get to that stage.
![]() |
| Street scene in 3DS Max |
I've imported the street model into Unity and edit it from there, so any changes I make in 3DS Max instantly appear for me to explore in-game. This way I can check scaling and the feel of things with ease as soon as I've made them. This also allows me to easily integrate my game mechanics with the street scene such as moving doors and interactive pieces when I get to that stage.
![]() |
| Street scene in Unity |
Monday, 16 November 2015
UI Card Game Part 2
With the main menu sorted from last week, the next objective was actually adding cards to the game scene. Rather than layout every card individually and be limited to the space available, we were taught a clever way to set up the scene so that cards are generated upon playing the game. In order to do this I needed to add a background to the game scene, which is what would control the card position and generation for me. The component that allows me to preset the positions and spacing of the cards is a 'Grid Layout Group', which has cell sizing and spacing values. I needed to add a few cards initially and set the cell size to fit the card, then adjust the spacing to my liking. From there I set the starting position (top left), alignment (middle centre) and constraint count i.e. number of rows(4).
Once the card layout was done I could clear all cards off the scene and start on the generating scripts. To start a card face is needed so we created a card model class that creates the variables, then a behaviour class which assigns them to the card. The next step was having a game controller that creates a grid list for cards to be generated into and then fills it. However this on it's own would put each matching pair together, so we need something to shuffle the cards around. We were provided with a complex method that made use of the generics we were taught two weeks ago by Richard. The method uses the 'RNGCryptoServiceProvider' class which is essentially a random number generator. From what I can gather, it uses this to generate a byte for a box position and then assign a card to that space. The finished product of this week is a game screen filled with shuffled cards.
![]() |
| Components in the background object |
Once the card layout was done I could clear all cards off the scene and start on the generating scripts. To start a card face is needed so we created a card model class that creates the variables, then a behaviour class which assigns them to the card. The next step was having a game controller that creates a grid list for cards to be generated into and then fills it. However this on it's own would put each matching pair together, so we need something to shuffle the cards around. We were provided with a complex method that made use of the generics we were taught two weeks ago by Richard. The method uses the 'RNGCryptoServiceProvider' class which is essentially a random number generator. From what I can gather, it uses this to generate a byte for a box position and then assign a card to that space. The finished product of this week is a game screen filled with shuffled cards.
![]() |
| Shuffled cards in game |
![]() |
| Shuffling code |
Saturday, 14 November 2015
Street Scene Project & Brainstorm
All of the game design work in recent weeks has been building up to be put in a GDD, where somebody can look through it and get an idea of exactly what my game is and how it should look. That section has been finished now and in it's place I have a new project. This is to construct an interactive street scene that is created in 3DS Max, then has a game created around it in Unity. Straight away my idea was to make the western high street I had planned for my game design process. I had already put plenty of thought and planning into how everything would look, so adjusting it slightly into a more open street would be no trouble and I'd love to see how it turns out. My inspiration for the design is going to follow the town of Armadillo from Red Dead Redemption, therefore this is almost going to be the guide I try to recreate. I won't be making the buildings look identical and will have my own take on them, the town layout is simply my aim.
As for the game aspect, I'd like to have a story based, walking simulator. As the entire point of the street scene is to make it look great, I'd much rather have the character explore the area and appreciate the scene rather than run around ignoring everything because they're too focused on a crazy objective of some form. I've planned out the story of a middle aged man who lost his wife and children along with his farm and home. With nothing left in the town he heads down the street towards the train station but along the way players will encounter glowing orbs of light. Upon walking into them, they will hear a voice recording where parts of the characters tragic backstory is revealed. The player needs to find every glowing light before they can head to the train station and leave town. The glowing light look that I'm aiming for is similar to the ones that appear in 'Everybody's gone to the Rapture'.
![]() |
| The town of Armadillo from Red Dead Redemption |
As for the game aspect, I'd like to have a story based, walking simulator. As the entire point of the street scene is to make it look great, I'd much rather have the character explore the area and appreciate the scene rather than run around ignoring everything because they're too focused on a crazy objective of some form. I've planned out the story of a middle aged man who lost his wife and children along with his farm and home. With nothing left in the town he heads down the street towards the train station but along the way players will encounter glowing orbs of light. Upon walking into them, they will hear a voice recording where parts of the characters tragic backstory is revealed. The player needs to find every glowing light before they can head to the train station and leave town. The glowing light look that I'm aiming for is similar to the ones that appear in 'Everybody's gone to the Rapture'.
![]() |
| Lights from Everybody's Gone to the Rapture |
Wednesday, 11 November 2015
Dark Arts 2: Singletons and Entities
In the second of our dark arts sessions we were taught about the uses of singletons and entities in our coding. As I've already covered the singleton pattern in Java, it was simple recap when Richard talked about how to use it, however it was very useful to see the examples he gave of where in a game it could be used such as for UI managers. The singleton pattern is where you set something up that is only created once and called anytime it's ever needed. This stops multiple copies of the same object from being instantiated, lowering the amount of errors you could get and also keeping memory management tidier. The downsides are that it isn't thread safe and everything can access it, which is just as useful as it is a liability.
Virtual methods were the second subject Richard covered, which are methods a class can essentially inherit from, unless the method is overwritten. Essentially it allows you to write one class with a lot of methods in for a variety of objects that will use them, but be able to change it for each object if needs be. The base class is essentially the game entity with all other classes using it if they require the methods.
![]() |
| How to instantiate and keep an singleton |
Virtual methods were the second subject Richard covered, which are methods a class can essentially inherit from, unless the method is overwritten. Essentially it allows you to write one class with a lot of methods in for a variety of objects that will use them, but be able to change it for each object if needs be. The base class is essentially the game entity with all other classes using it if they require the methods.
![]() |
| Example of two classes using a base class but one overriding the method |
Monday, 9 November 2015
UI Card Game
Over the next 3 weeks I'm going to be taught how to use the UI system in Unity to it's full capabilities. The game is a simple copy of a card matching game where you flip the cards to try and find the pairs. This first week covered the basics of the new Unity canvas system and how to make a menu from it. The first step was to add the background for our menu that everything else will be laid on top of. I needed to play around with the anchoring to make sure the background covered the whole screen upon playing the game.
The next focus was adding buttons so the player can navigate from the main menu to the actual game.
Buttons in Unity 5 are far easier to use because they come with a preset OnClick() section. All I had to do in order to make a working button was create a script containing no more than:
public void LoadLevel(int _levelIndex)
{
Application.LoadLevel (_levelIndex);
}
This is all that is needed to create a loading button. I checked the build settings so I new which scene had which number, then added the script and game number into the button script. When I started up the game and pressed play, it took me straight into the game scene. I then just needed to position the button using anchors again then add a title and I had finished the main menu.
The next focus was adding buttons so the player can navigate from the main menu to the actual game.
Buttons in Unity 5 are far easier to use because they come with a preset OnClick() section. All I had to do in order to make a working button was create a script containing no more than:
public void LoadLevel(int _levelIndex)
{
Application.LoadLevel (_levelIndex);
}
This is all that is needed to create a loading button. I checked the build settings so I new which scene had which number, then added the script and game number into the button script. When I started up the game and pressed play, it took me straight into the game scene. I then just needed to position the button using anchors again then add a title and I had finished the main menu.
![]() |
| Finished menu screen |
Wednesday, 4 November 2015
Dark arts 1: Generics
This week we had the first of our ‘Dark Arts’ sessions with
Richard Weeks. Richard is head of a company called Total Monkery that operates
from Plymouth and we’ve been lucky enough for him to come in and teach us some
industry standard programming methods. Having somebody who runs his own company
and has experienced the games industry first hand come in to teach us is an
excellent opportunity. While what I’ve learnt so far at University has been
essential, Richard is going through ways to make Unity work in ways it normally
wouldn’t, hence why these are called ‘Dark Arts’ sessions.
The first session covered generics. This allows us to make
custom types for classes, methods and variables which has lots of uses. When
used for a class, it allows the user to get the variables and constructors, meaning
you can create objects in the generic class from another. When using a generic method, the type of object you want to pass in must be specified before the parameter, this way a single generic method can perform an operation on many varying data types. One example (shown below) is a method to create entities where a list of different entities can all be passed in. Dictionaries can use generics to form lists with a variety of different types by having a generic key with a corresponding value.
In an example we were shown, one method assigned class types and names, while the other passed in a large variety of different types of entities.This is something I could use in my game to make it less prone to errors and easier to work with as a whole.
![]() |
| Entity inheritance example |
Wednesday, 28 October 2015
Xbox Controllers
For my game I need to have different types of input so that
two people can play the game at the same time. Obviously for a PC game I’m
going to use the mouse and keyboard for one player, then for the other I’m
going with an Xbox controller as it’s set up to work well in Unity. Setting the
input axes for the controller has been quite simple and I think it’ll be easy
to implement the controls into my final game.
To start with I wanted to add movement and look inputs. I
discovered that the input manager is already configured to move the player with
the left stick which saved me one job, however the right stick look controls
needed to be implemented. I needed to create 2 new inputs called Controller
look X/Y which were set to the 4th and 5th axis
respectively. Upon playing the game, right stick caused the player to look around, although the Y axis was inverted so I simply checked the box the reverse it.
![]() |
| Two custom inputs |
The other things I wanted to play around with was adding the ability to sprint, crouch and jump from the controller. I decided that the controls I wanted were: pressing in left stick (8 on diagram) would sprint, A (0) would jump and B (1) would crouch. Each of these were surprisingly easy as all I needed to do was add an OR condition to my if statements that check the corresponding action can be performed. This solution means that the player can move with either the keyboard and mouse or controller, so for my actual game I’ll need to add a check at the very start of the movement script to assign each player a single input type rather than the ability to use both.
![]() |
| Xbox controls map for reference in Unity |
Monday, 26 October 2015
Leap Controllers
Using the Leap motion controller was definitely a new
experience for me. It works by using infrared cameras and registering what
objects appear in the way, rendering them into game objects. I personally don’t
think I’ll be using them in my game but it was a fun experience and I had a few
ideas about what they could be used for nonetheless. We were provided with a
Unity project containing lots of different scenes that showed off the Leap’s
uses and we were told to have a play around, getting use to this new tool.
The first scene simply showed the users hands and responded
to you doing different things like clenching your fist, wiggling your fingers
and moving them around. This scene is only to show how the Leap controller
registers you, so doesn’t have much to do in it.
![]() |
| Simple hands scene |
The next scene allowed me to interact with an object, in
this case a flower. The flower grows in the centre of the screen allowing you
to pick it and hold it. From there you can move it around to look at it and
even pull off petals one at a time. This could be a little fiddly at times and
the Leap can be a little temperamental, especially if something is covered from
below so the Leap can’t see it entirely. However this was a nice little scene
to show some basic interaction.
![]() |
| Scene showing how delicate the Leap can be |
My favourite scene was where you had 6 little cubes that you
could gently pick up and stack upon one another. Again the Leap could have
slight problems of freaking out making it very difficult to stack all of the
cubes, but as long as your hand wasn’t too near the tower you would be alright.
This example of the ability to move objects around and place them down could be
very useful in a two player platform game of some form.
![]() |
| Tower stacking scene |
The final scene was very enjoyable and contained a room full
of boxes which the user can scoop up and throw about at will. This is more of
an example of mass movement/control over a situation using the Leap. It was
quite fun and relaxing to spend a minute or two throwing boxes around and
watching them bounce off the walls for a while.
![]() |
| Messy block scene |
Thursday, 22 October 2015
3D Materials
For design work this week we focused on improving texturing and the appearance of objects when they are imported from 3DS Max into Unity. Setting a block of colour to an object gives it a very unrealistic appearance so effects can be used to make them look much nicer. In real life, objects like walls are slightly bumpy and never completely smooth, therefore adding a single sheet of colour will make it look strange. This can be helped by adding a layer of noise, which will create a form of static and make the wall look slightly bumpy, giving it an overall more realistic feel.
To practice to texturing we did last week, we were tasked with creating a cube and adding a different texture to each side. The six different textures were: brick, gravel, window, carpet, clean wall and dirty wall.
We then went into Unity and learnt about editing materials to change their appearance and tailor them to specific objects. The two settings we focused on were metallic and smoothness. The metallic setting determines how light is reflected off the object; the higher the setting, the more reflective the object is and the less colour is visible. Smoothness increases the objects micro surface detail and makes things look more or less glossy. For example, a wooden or stone object will have very little, if any, of either of these settings. Whilst a plastic or metal object will have larger values of each.
The final thing we were taught was that when an object from 3DS Max is imported into Unity, it's textures can be edited to change the materials appearance. This is very useful when you import an object and want to make the separate components look like different materials. To practice this I created a table in 3DS Max and imported it, then changed the settings to make the legs look metallic and the actual table top look like varnished wood with a plastic edging.
To practice to texturing we did last week, we were tasked with creating a cube and adding a different texture to each side. The six different textures were: brick, gravel, window, carpet, clean wall and dirty wall.
|
|
We then went into Unity and learnt about editing materials to change their appearance and tailor them to specific objects. The two settings we focused on were metallic and smoothness. The metallic setting determines how light is reflected off the object; the higher the setting, the more reflective the object is and the less colour is visible. Smoothness increases the objects micro surface detail and makes things look more or less glossy. For example, a wooden or stone object will have very little, if any, of either of these settings. Whilst a plastic or metal object will have larger values of each.
![]() |
| Stone(left), plastic(centre) and metal(right) materials |
The final thing we were taught was that when an object from 3DS Max is imported into Unity, it's textures can be edited to change the materials appearance. This is very useful when you import an object and want to make the separate components look like different materials. To practice this I created a table in 3DS Max and imported it, then changed the settings to make the legs look metallic and the actual table top look like varnished wood with a plastic edging.
|
|
Wednesday, 21 October 2015
Fading Bullet holes
When I was playing around with the bullet holes, something I definitely wanted to do was cause them to fade out over time rather than just disappear immediately. The effect is slow and subtle so won't pull people out of the immersion of the game unlike constantly destroying the texture instantly would. After a bit I research I discovered that textures have an alpha setting along with the RGB settings. Alpha is the transparency of the texture, so in order to get my bullet hole texture to fade I needed to adjust the alpha setting over time. The way I thought of doing this was to use the interpolation mechanic I'd been taught the other week, to slowly adjust the setting from max to 0 over the course of three seconds.
After figuring all of this out and getting it to work I added it to my prototype scene to show it off.
![]() |
| Fading alpha interpolation code |
After figuring all of this out and getting it to work I added it to my prototype scene to show it off.
![]() |
| Bullet hole partially faded |
Monday, 19 October 2015
Pendulums and More Shooting
Continuing on from last weeks work about shooting, we added a few modifications to the scene. The first addition was adding a cross hair so the player could see where they were going to hit when firing. Using the new Unity 5 UI system makes adding text and images to the UI incredibly easy. Rather than having to code the entire object in a script, you can add a canvas to the scene and place an object upon that canvas. For images just move it into the position you want and for text items, do the same them add the text in and even stylise it if needs be. So I placed the cross hair image dead center of the screen, adjusting my bullet spawner to fire at the same point upon clicking.
![]() |
| Cross hair in scene used to destroy block |
The second thing added to my shooter this week was a bullet hole upon impact. In order to do this I had to use Ray Casts for the game to judge on whether an object would be hit upon firing. If this is found to be true then a bullet hole will be instantiated at the point of impact giving a more realistic affect to the scenery. To stop graphical glitches, the bullet hole is not applied directly onto the object it hits, but set as a quad 0.01 units in front of the collision point. This stops the created bullet hole and target object from fighting for the same world space and flickering when looked at by the player.
![]() |
| Bullet hole created by bullet collision |
When this was all implemented however, I very quickly found that the holes stacked upon one another. On top of this, since they were just placed where there was a collision, if the object the bullet hits gets moved then the bullet hole is left floating in space. To solve the first problem I needed to destroy the bullet holes after a little while to stop them from filling up space, so created a script which waited for 3 seconds after being created, before destroying it. To stop floating holes I had to set the object getting hit as a parent of the bullet hole. This means wherever the object hit goes, the bullet hole will go with it.
| Code to create bullet hole and set object collided with as parent |
After we finished with the new shooting mechanics, we moved onto something new: pendulums. Making a pendulum was surprisingly quick and easy, since all you need to add to an object is a Rigidbody and a hinge joint. When applying the hinge joint you add the object that will be the connected body and that causes the two objects to act as a hinge. Adding multiple objects in a row and hinging each to the previous one creates a chain that we added a sphere to the end of. After creating a wrecking ball it only made sense to add a wall to knock down with it, which is exactly what I did.
| Pendulums swinging to destroy wall |
Wednesday, 14 October 2015
Improving Catapult Mechanic
Whilst the catapult worked perfectly well, a few improvements could be made to make it more efficient/rounded. My first improvement was only allowing the object to aim and jump if the mouse is clicked whilst hovering over the object. In order to do this I needed to register the mouse position upon the person clicking. I set a ray cast to fire from the camera from this point and to see if it hit the box. If so then a Boolean 'hasClicked' is set to true, else it remains false. If the Boolean is true then the player has clicked on the object so can now fire it, otherwise nothing happens.
![]() |
| Object with aim dots showing path |
The second improvement was altering the force applied depending on how far back the mouse was dragged. So the object can perform either a large leap, small hop or anything in between. To solve this issue I was required to use a few simple projectile physics equations that determine the distance based on the velocity and gravity. Once the equations have worked out the distance travelled, the position of the dots could be adjusted to create the new flight path of the object. As all of this is in a method called within update, the path will update in real time based on how the player is angling the shot.
![]() |
| Physics equations applied |
This way, clicking on the object and moving the mouse to aim and apply force gives the feeling of pulling something back in order to fire the object forward.
Subscribe to:
Posts (Atom)


































