I would like to print when only a certain type of object is hit by my raycast (a creature’s awareness range for food).
I very easily could use the physics masking system to accomplish this same thing, but what happens when I have 40 different objects I’d like to differentiate? A non-masking solution also allows me to throw fewer rays to get the same job done.
This is how far I’ve come but it throws an error, saying I need to export a trait. I understand I’m referencing a trait that doesn’t exist but I don’t know the right way about it; I’ve been on it a couple of hours.
I picked up armory3D earlier this week but have used BGE before, so I just need some help through this part, as BGE had property detection built into the near and raycast sensors and such.
the “needs to export the trait” error is because there is no “object” in your game with the trait you want to use
just assign the “trait” to a object .
Basically, you must have an “object” in the scene with its “trait” to be able to use it in the game.
It is at least what I understand, since the same thing happened to me a while ago.
It could also be that you are calling a “trait” that is in the scene, but the “name trait” is wrong
To add to what @ Obi_NO_Wan_Kenobi already wrote:
A trait and a logic tree are two different but very related concepts. A logic tree is completely independent of any object in the first place. It’s just an isolated place where you define some logic/behaviour. In order to actually execute that logic, you need to add a logic node trait to an object (or to the scene) which references the logic tree. So a single logic tree can be reused multiple times by different traits (unlike logic bricks in BGE if I remember correctly, where a set of logic bricks belongs to one specific object).
If you know object oriented programming: logic trees get transformed into classes, and logic node traits are instances/objects of the class of the logic tree they are referencing.
It’s unfortunately very easy to forget to apply a trait to an object after you created a logic tree, but given the fact that logic trees are independent of any object it’s rather difficult to implement a more fail-safe way of handling this. If you have any ideas feel free to share them
Btw, if you come across other issues in the future, please always include the specific error message (if there is any) as it can contain valuable information about what exactly went wrong.
It’s funny. I decided to add this topic to my list to make a “back to the basics” tutorial for node trees (the difference and importance of assigning object nodetrees and scene ones) And I guess It is a vital concept to understand and one that is not really taught yet. I’m working on a video about tweens and will make this topic my next priority.
by the way, considering that you come from using (BGE) and maybe you don’t know how to add a (trait) to an (object/scene).
here I leave you 2 reference images.
just click on the (+) and select (Nodes)
in the same way for the scene traits
in case you still get the error, can you share a screenshot of the console…
Hi guys thanks for the feedback.
I’m very aware of how a trait and a logic tree are different.
My question is how to use a raycast to detect only instances of a certain class. I don’t particularly care to detect any nodes; In my test file the object I’m trying to detect has a trait added to it (I checked your screenshots to make sure I’d done it right) and in fact, the trait has no nodes assigned and is saved by a false user as well.
It seems a lot of you guys are hinting I should be using a scene trait to run detection between two objects, is this the case?
I’m not incredibly concerned about that particular error message either, it was one in a series of similar messages I knew I would be provoking, and I only referenced it because I showed a snippet of faulty logic to try and explain what my goal is but there seems to be a communication block.
TLDR I would very much like to set a boolean TRUE if an object possessing the “food” trait (or any string name I enter) is hit by my raycast, but ONLY objects possessing that trait.
Worth mentioning perhaps that a property-based answer is acceptable as well.
I tried earlier with the scene setting all food objects (based on their name) with a property “food”, but on the creature side I still could not figure out the logic to make the ray-hit behavior only accept object of that property.
we definitely had a (comprehension/expression) problem…
In any case, here is a blende file with raycast (normal) and another with (property).
In the file, you will notice that there are 2 cubes, the (green cube) has no property.
the (red cube) if it has.
You will notice that the cube (green) will reach the end of the path and hit with it (normal raycast).
while the cube (red) will hit the raycast that verifies if the object has the property (food)
When hitting the cubes, they will return to the (empty) position…
I think this is what you need, in which case, don’t hesitate to upload your .blend to review it
.blend modified and reuploaded for those who need them in the future
that little snippet is not null is what i was after tysm. not sure how to mark a thread as solved
Beyond using a 3rd-party plugin like BlenderArtists uses, there isn’t really a “solution” or “solved” button, but people can include “solved” word in their thread title, as well as assign the #solved tag to their thread - I already did this to save you the trouble, just sharing this for anyone who’s curious.
oh. I appreciate it. Regarding the use of node trees as classes, if I have a node tree like this one;
and I wish to obviously pass it a float and a vector, and be returned a vector, how can I call this tree from another function?
Does it not already return a vector float? What value(s) does it return then?
Using Haxe or Logic Nodes?
using nodes… I had all my functions in one large tree and it was getting too messy. So far I don’t know enough about using nodes as classes to call it at all, as I’ve just begun breaking down my logic into more usable chunks.
I guess my question is: regardless of which node tree (but using the one above as an example) what do I have to do to call one tree from another. and specify which variables I wish to pass and return?
The Call Node Group node is what you’re looking for then I believe.
However, as mentioned here it’s buggy and could use a source restructure.
Can I call node groups from haxe then?
- To run a NodeTree at runtime, you don’t need Haxe, just enable it directly via Blender UI.
I don’t think you can enable a NodeTree dynamically at runtime (I could be mistaken), because in order for a NodeTree to be used at runtime, it needs to be included in the compiling process. The Call Node Group node gets around this problem by retrieving synced nodes on export and compiling them, but that’s before runtime and in the pre-runtime compiling process.
- If you’re comfortable with using Haxe, I’d suggest using separate Haxe scripts instead of Logic Nodes. You could even use just one large Haxe Script that contains numerous functions that you can call individually at any time - this is probably the closest you can get to toggling predefined sets of logic at runtime. You could also mix-and-match and use numerous scripts that all contain numerous functions, all of which can be called from each of the other scripts.