|
Fano posted:Shouldn't you be returning true at the end of the function? What is "walkable" assigned to? walkable is a boolean assigned from the inspector, it's set to false for tiles which are never, ever walkable. xgalaxy posted:I don't believe you. Your code looks correct but the transform you give to Sphere looks fishy based on your explanation. I'll have to double-check the coordinates then. Unfortunately I don't have any time before I have to go to work. If it's useful, here's the entirety of my pathfinding method: code:
|
# ? Oct 2, 2015 19:04 |
|
|
# ? Jun 7, 2024 05:04 |
|
Figured it out: I was using transform.localPosition when I should have been using transform.position. I'd always been using localposition, and it had been working, but all of my map tiles are parented to a gameobject for keeping them together, so that was what screwed me up.
|
# ? Oct 3, 2015 15:27 |
|
Is there a thread for basic OpenGL related questions? I struggle with some very basic poo poo. I have this 2d game, all of my objects are 2d polygons that exist on the xy plane, when I use orthographic projection with glOrtho everything works well: code:
but now if I try to comment out gl.glOrtho and try to use regular perspective projection just moving the camera a bit back on the Z axis so that it would point at the exact same plane (only without the orthographic projection) I all of a sudden don't see anything at all, I tried at first simply using gl.gltranslatef(0.0f,0.0f, -6.0f) and it doesn't work, then I tried using gluPerspective, same results... I figured my camera might be pointing in the wrong direction but then when I used glu.glulookat(0,0,-6,0,0,0,0,0,-1) - that is camera at 0,0,-6 looking at 0,0,0 pointing towards the negative Z direction - I still can't see anything. I'm really quite confused cause this should be rather trivial, if I can see the painted vertices projected orthographically why can't I see them with non-orthographic projection just pointing toward the plane the vertices are on? I can share my code if anyone would fancy taking a look, alternatively I'd also appreciate recommendations for solid articles\tutorials\books about OpenGL and using projections, I'm just very confused about this whole thing.
|
# ? Oct 4, 2015 12:47 |
|
emanresu tnuocca posted:Is there a thread for basic OpenGL related questions? I struggle with some very basic poo poo. - Even though your stuff is 2D, you need to make sure they are within the perspective camera's near and far plane (z axis) - Also make sure the camera is pointed at the front side and not the back side.
|
# ? Oct 4, 2015 20:24 |
I would think you would want your up vector to be on the Y axis if you're offsetting the camera on the Z axis. Try glu.glulookat(0,0,-6,0,0,0,0,-1,0)
|
|
# ? Oct 4, 2015 21:10 |
|
emanresu tnuocca posted:Is there a thread for basic OpenGL related questions? I struggle with some very basic poo poo. there's this http://forums.somethingawful.com/showthread.php?threadid=2897255 If it renders with an orthographic projection it's almost certainly your perspective projection parameters which you didn't post. Manslaughter posted:I would think you would want your up vector to be on the Y axis if you're offsetting the camera on the Z axis. Try glu.glulookat(0,0,-6,0,0,0,0,-1,0) Sex Bumbo fucked around with this message at 21:13 on Oct 4, 2015 |
# ? Oct 4, 2015 21:11 |
|
Yeah I had to switch the up vector to the y axis as you guys said, and I was also looking at the projection from below which wasn't good, and on top of that I had a method I used to zoom out of the orthographic projection that was still doing its thing in the background that was messing things up. So yeah, that's pretty cool. Thanks for the help.
|
# ? Oct 4, 2015 21:36 |
|
Is there a simple way to handle some polymorphism with a component in Unity? I want to have a component provide an implementation of an interface for being interacted with by the environment. The interactions are basically "use key" kind of things: opening doors, opening chests, and hitting a button. I'd like to attach code to these objects to behave different when this stuff happens. How might I do that cleanly? As it stands, I have a MonoBehavior that just contains an instance of my interface for world interaction. I then have components for this or that interaction that implement the interface. I have to remember in the Start() method for them to look up the component that contains the generic interface and replace that with a reference to the this component. Then things that want to perform a use on the environment don't need to know what exactly they're interacting with, so long as the object has the component that exposes world interaction. It just seems very fragile.
|
# ? Oct 5, 2015 07:25 |
|
How to make sprites? I think I should start working on graphics for my game, but I'm kind of terrified of any method because of my lack of experience and that it's going to take an unbearable amount of time. I started out thinking that I'd render stuff in Blender, but now that I should actually get down to it I'm realizing that in the past I've taken months to create a relatively simple model. The thing is, out of all kinds of art I've tried, my Blender models have been the most aesthetically appealing, I think (although the adjective "lovely" would certainly be applicable), and there's certain advantages if you've never done traditional animation.
|
# ? Oct 5, 2015 12:21 |
|
Rocko Bonaparte posted:Is there a simple way to handle some polymorphism with a component in Unity? I want to have a component provide an implementation of an interface for being interacted with by the environment. The interactions are basically "use key" kind of things: opening doors, opening chests, and hitting a button. I'd like to attach code to these objects to behave different when this stuff happens. How might I do that cleanly? (Again with the caveat that I don't actually use unity) When you implement an interface this indicates to whichever collection of objects that might reference an object that this object can perform certain actions, say, if you have a "hasLock" interface and an "openable" interface and you have a door object implementing both interfaces it's gonna look something like this: code:
code:
https://unity3d.com/learn/tutorials/modules/intermediate/scripting/interfaces Apologies if I misunderstood your question and my answer is referring to some basic poo poo you already knew.
|
# ? Oct 5, 2015 13:09 |
|
GameObjects can't be extended and can't implement interfaces though. So you would have to do something like GetAllComponents on a gameObject and then traverse that component list to get all of the components that implemented openable. You could wrap this in an extension method to GameObject though. The function you are looking for would be: code:
code:
xgalaxy fucked around with this message at 16:23 on Oct 5, 2015 |
# ? Oct 5, 2015 16:10 |
supermikhail posted:How to make sprites? I think I should start working on graphics for my game, but I'm kind of terrified of any method because of my lack of experience and that it's going to take an unbearable amount of time. I started out thinking that I'd render stuff in Blender, but now that I should actually get down to it I'm realizing that in the past I've taken months to create a relatively simple model. The thing is, out of all kinds of art I've tried, my Blender models have been the most aesthetically appealing, I think (although the adjective "lovely" would certainly be applicable), and there's certain advantages if you've never done traditional animation. Spriting takes more time and effort than everything else combined. Offload that crap to someone else!
|
|
# ? Oct 5, 2015 17:10 |
|
xgalaxy posted:GameObjects can't be extended and can't implement interfaces though. So you would have to do something like GetAllComponents on a gameObject and then traverse that component list to get all of the components that implemented openable. You could wrap this in an extension method to GameObject though.
|
# ? Oct 5, 2015 17:11 |
|
Why not have an Openable component and attach that to everything that needs to be opened? I feel like you're not embracing the Entity/Component pattern and trying to force everything to be strict OOP.
|
# ? Oct 5, 2015 21:00 |
|
Rocko Bonaparte posted:I was going to say how surprised I was that I could just cast the game object to the interface. That would have to be some Mono voodoo. I was going to try it tonight just to see, but this sounds more like reality. Extension methods always leave me initially sour, but I think this is less likely for me to screw up when implementing multiple instances of the interface for all the different things. You can also use inheritance from an abstract class instead of interfaces, which tend to work better with Unity's newer generics-based API. gameObject.GetComponent<MyAbstractClass>() will get you any component that inherits from that class, with virtual functions functioning as you would expect.
|
# ? Oct 5, 2015 23:55 |
|
orenronen posted:You can also use inheritance from an abstract class instead of interfaces, which tend to work better with Unity's newer generics-based API. gameObject.GetComponent<MyAbstractClass>() will get you any component that inherits from that class, with virtual functions functioning as you would expect. GetComponent<IWhateverClass>() does the exact same thing with interfaces. I use it a lot. It uses to work differently but they updated it sometime in late 4.x from what used to be an undocumented feature for the other GetComponent.
|
# ? Oct 6, 2015 00:56 |
|
poemdexter posted:Why not have an Openable component and attach that to everything that needs to be opened? I'm in a strange gray area in the design right here. The issue is when the player wants to interact with the environment, I don't want to have to code for every possibility right there in the player control code. The possibilities are ultimately going to be finite, so I could just suck it up and test for all of them, but I'd rather just scan all the game objects in the use area, see if they are capable of being interacted with, and then just tell them to be interacted with the player. This without knowing exactly what the interaction might be. So I figured an interface would give me that disassociation, but I can't figure out then how to tie it to a component that states it's capable of being interacted with this way. FuzzySlippers posted:GetComponent<IWhateverClass>() does the exact same thing with interfaces. I use it a lot. It uses to work differently but they updated it sometime in late 4.x from what used to be an undocumented feature for the other GetComponent. I have 4.6.8f1 and this doesn't seem to compile. It's complaining I can't cast my IWorldInteractable to UnityEngine.Component. Here's what I'm doing: code:
|
# ? Oct 6, 2015 01:27 |
|
FuzzySlippers posted:GetComponent<IWhateverClass>() does the exact same thing with interfaces. I use it a lot. It uses to work differently but they updated it sometime in late 4.x from what used to be an undocumented feature for the other GetComponent. Huh, I just tested it in 5.1 and it does indeed work. I know for a fact it didn't used to, so I probably just missed the fix along the way. Still, querying for classes up the inheritance tree have always worked, and it may even be the better solution if you want to implement some default behavior.
|
# ? Oct 6, 2015 02:05 |
|
The 4.6 release notes state:quote:Added smart-allocating GetComponents<List> method which fetches components of type T and grows the list as needed. Non-generic version that supports interfaces has also been added. Edit: Oh the non-generic version! Literacy! code:
Rocko Bonaparte fucked around with this message at 02:23 on Oct 6, 2015 |
# ? Oct 6, 2015 02:20 |
|
Rocko Bonaparte posted:
Incidentally, I think this is made a much bigger deal than it actually is. foreach is perfectly fine unless you're calling it thousands of times in an inner loop or something - our code (for a decently sized game) uses it quite a bit, even in Update methods, and performs perfectly well on years old mobile devices. I say use foreach and LINQ and the other stuff Unity programmers like to warn against. If you're responsible in your coding and know what can actually go wrong with them they're amazing for code clarity and simpleness.
|
# ? Oct 6, 2015 02:43 |
|
orenronen posted:Huh, I just tested it in 5.1 and it does indeed work. I know for a fact it didn't used to, so I probably just missed the fix along the way. Definitely for some things, but like lately I've been dealing with a bunch of different objects you can click on in a world space map. Since the objects are otherwise unrelated it makes sense to me to have an IMapClickable interface that anything can implement and respond to. I'm glad using interfaces has been improved as I think the "Unity way" for this kind of problem previously used to be to use SendMessage (which I hate) or have a clicker monobehaviour you attach to everything and interfaces can be a lot simpler implementation. Presumably somebody at Unity works there now who's really on the interface bandwagon since all the new UI stuff works through interfaces so they added more functionality for using them. FuzzySlippers fucked around with this message at 02:59 on Oct 6, 2015 |
# ? Oct 6, 2015 02:52 |
|
orenronen posted:Incidentally, I think this is made a much bigger deal than it actually is. foreach is perfectly fine unless you're calling it thousands of times in an inner loop or something - our code (for a decently sized game) uses it quite a bit, even in Update methods, and performs perfectly well on years old mobile devices. Its best to avoid LINQ if you are targeting an AOT only device, such as iOS. While there are large portions of LINQ that are perfectly fine on mobile, there are other parts that are not and will throw runtime exceptions on the device and it is often hard to track down where the error is coming in after the fact. I'm not sure if IL2CPP changes this at all or not, and AOT errors in general. Anyone know? My guess is that since IL2CPP is just another form of AOT compilation that it is going to have the same limitations and that LINQ still won't 100% function. Anyways, if you really want to use LINQ than use either this or this. I agree with you about the foreach situation though. Best to just use foreach and only change loops that you actually find to be a problem and then only after profiling it. xgalaxy fucked around with this message at 06:36 on Oct 6, 2015 |
# ? Oct 6, 2015 06:24 |
|
xgalaxy posted:Its best to avoid LINQ if you are targeting an AOT only device, such as iOS. While there are large portions of LINQ that are perfectly fine on mobile, there are other parts that are not and will throw runtime exceptions on the device and it is often hard to track down where the error is coming in after the fact. Our game is mobile for both iOS and Android and we're using LINQ (as well as stuff like Reactive Extensions) heavily. Just like with foreach, as long as you actually understand what the potential problems are and why they're there, they're very easy to avoid. il2cpp doesn't solve any of it - the code it generates is still equivalent to AOT.
|
# ? Oct 6, 2015 06:46 |
|
orenronen posted:Our game is mobile for both iOS and Android and we're using LINQ (as well as stuff like Reactive Extensions) heavily. Just like with foreach, as long as you actually understand what the potential problems are and why they're there, they're very easy to avoid. Can't help but feel that this is easier said than is actually witnessed in practice. Is there a list online somewhere that details which parts of LINQ will have potential problems and under what circumstances? In the past I've used parts of LINQ that seemed perfectly fine with some set of types and then blew up with AOT runtime exceptions on other types. Oh that type didn't specify a default IEqualityComparable, sorry - have an AOT exception.
|
# ? Oct 6, 2015 07:02 |
|
EDIT: figured it out. DStecks fucked around with this message at 18:58 on Oct 6, 2015 |
# ? Oct 6, 2015 17:28 |
|
Does anybody have an existing, nice little angle calculation helper? I'm dealing with shenanigans like testing if something is rotated to -90 degrees, and finding out instead it's rotated to 270 degrees. I'm scribbling it as a I go, but I am willing to shamelessly draw upon some helper code if there is some.
|
# ? Oct 8, 2015 00:57 |
|
Rocko Bonaparte posted:Does anybody have an existing, nice little angle calculation helper? I'm dealing with shenanigans like testing if something is rotated to -90 degrees, and finding out instead it's rotated to 270 degrees. I'm scribbling it as a I go, but I am willing to shamelessly draw upon some helper code if there is some. I struggle with this every single time it comes up haha
|
# ? Oct 8, 2015 00:58 |
|
Looks like a job for the modulus operator: code:
So for Unity: C# code:
Telarra fucked around with this message at 01:54 on Oct 8, 2015 |
# ? Oct 8, 2015 01:52 |
|
I'm talking more than modulus. Like, I wanted to tell when some rotation is within 2 degrees of another rotation. And then there's shenanigans with wrapping 0 degrees and 360 degrees. Also, finding the shortest distance between two angles. There's just lots of stupid little things that I don't image are really worth coding over again.
|
# ? Oct 8, 2015 04:42 |
|
The thing that gets me is trying to interpolate smoothly between two angles. Takes me forever to get it to always rotate the shortest way.
|
# ? Oct 8, 2015 05:02 |
|
Moddington posted:So for Unity: Put -50 in there, you risk getting (if the modulus is one that doesn't mind returning negatives) 50 rather than the expected 310. What generally works (caveat; can break if direction changes are >360 in one rotation) is (angle+360)%360. To also be immune to the caveat, you could do ((angle%360)+360)%360. Then for angle comparisons you can do something like: code:
This is not optimized though.
|
# ? Oct 8, 2015 07:47 |
|
If you're using Unity, and you're trying to find the difference between two rotated objects, you could use Quaternion.Angle on their rotations. If you have Vector2s or Vector3s there's Angle functions for both of those too; all of these will give the shortest angle between the two rotations/vectors.
|
# ? Oct 8, 2015 08:37 |
|
It's 4:30am and I just finished a thing in three weeks. It only looks right in Chrome, because Firefox doesn't understand using more than one canvas. There isn't a lick of balance on anything yet. You'll have to go dig into the types file to learn what poo poo does. Sounds will go in over the weekend. I think I still have to do the dirty left-right hack for panning. http://caliber.online
|
# ? Oct 8, 2015 12:41 |
|
Ranzear posted:It's 4:30am and I just finished a thing in three weeks. So ramming is apparently pretty effective? If by effective, I mean your health bars both expand until they're off the screen Also, the LC model seems to have issues with actually firing. If you don't shoot the whole burst it takes forever to reload/recharge/whatever, it seems like, and you can't finish shooting off the rest of that burst. ZombieApostate fucked around with this message at 13:11 on Oct 8, 2015 |
# ? Oct 8, 2015 13:09 |
|
Isn't it generally a lot better to work with radians rather than angles? All of the trig functions in most languages expect values to be in radians anyway and it's just something you got to get used to.Ranzear posted:It's 4:30am and I just finished a thing in three weeks. That's pretty cool, my feedback is that it's initially a little bit confusing to figure out which way your tank is pointing towards as it is all a solid color and the turret can rotate, would be nice to have an intuitive way to always figure out your orientation (even it's just a slightly different color on the 'front' of the tank).
|
# ? Oct 8, 2015 13:13 |
|
Ranzear posted:It's 4:30am and I just finished a thing in three weeks. chrome Version 45.0.2454.101 m posted:WebSocket connection to 'ws://caliber.online/' failed: Error during WebSocket handshake: Unexpected response code: 200 edit: Maybe it's because I'm at work? Tres Burritos fucked around with this message at 13:17 on Oct 8, 2015 |
# ? Oct 8, 2015 13:13 |
|
ZombieApostate posted:So ramming is apparently pretty effective? If by effective, I mean your health bars both expand until they're off the screen There is indeed collision damage, but I have no idea why it'd be healing tanks nor why the damage function wouldn't be keeping it positive... There's supposed to be a partial cooldown reset on a canceled burst. Also, you can totally shoot down missiles with bullets (but not shells). You would have trounced me with LC vs HK. Edit: code:
Ranzear fucked around with this message at 13:33 on Oct 8, 2015 |
# ? Oct 8, 2015 13:13 |
Rocko Bonaparte posted:I'm talking more than modulus. Like, I wanted to tell when some rotation is within 2 degrees of another rotation. And then there's shenanigans with wrapping 0 degrees and 360 degrees. Also, finding the shortest distance between two angles. There's just lots of stupid little things that I don't image are really worth coding over again. I may be misunderstanding what you're trying to do, but if you have two direction vectors can't you just dot the two and compare them with cos(angleToCompare)? Dotting should give you the cosine of the smallest possible angle between the two, and in most (if not all) implementations cos() gives you a value between -1 (for an angle of 180 degrees or pi radians) and 1 (for an angle of 0 radians/degrees.) If you have two rotations, then apply them to any unit vector (e.g. vec3(1,0,0)) and do the comparison between those two. E: Mix up on acos and cos. Joda fucked around with this message at 13:39 on Oct 8, 2015 |
|
# ? Oct 8, 2015 13:31 |
|
I still got stuck where I couldn't shoot anymore with the LC and I think you saw what happened when ramming Maybe the shooting problem has something to do with trying to shoot before the recharge is finished?
|
# ? Oct 8, 2015 13:33 |
|
|
# ? Jun 7, 2024 05:04 |
|
ZombieApostate posted:I still got stuck where I couldn't shoot anymore with the LC and I think you saw what happened when ramming It fires in a burst of five, and now just refunds a proportion of the (really long) cooldown based on how many you didn't fire. Time for more armor on LC, and Harasser's damage was pathetic (I think it hadn't been touched since armor values all got roughly doubled). The minelayer might be the gooniest tank... Ranzear fucked around with this message at 14:02 on Oct 8, 2015 |
# ? Oct 8, 2015 13:43 |