Browsed by
Category: Unity

Detecting Property Changes

Detecting Property Changes

My little rant generated some questions that it may be easier to clear up here than 140 characters at a time. Sometimes you want to execute some functionality when changing the value of a property. The key word there is “changing”. In order to know if the property changed you must compare the new value to the current value. It looks something like this: // some field in your class int value; void SetValue(int newValue) { if (value != newValue)…

Read More Read More

Unity Vector Comparison Rant

Unity Vector Comparison Rant

I recently ran into an interesting Unity feature that I didn’t know about previously. I kept having an agent get stuck in the same place for no apparent reason. I’ve spent two days trying to track down the problem and finally ran across this in the least expected place – a function written almost on day 1 of this project, over a year and a half ago. I’m trying to set my x position┬áto 32. Since I’m generating an event…

Read More Read More

Create a GameObject Image Using Render Textures

Create a GameObject Image Using Render Textures

On occasion when making a video game there is a need to display a texture that contains an image of a 3D game object. For example, to display in a toolbar, or chat message or something similar. These images could be created statically by your artist, but sometimes the image needs to change based on something happening in the game, or there is some other compelling reason where runtime creation is required. Render Textures are a straightforward method for creating…

Read More Read More