Unreal Engine Blueprint: how to move actor along spline? - unreal-engine4

In my game there is an Actor implemented in a Blueprint. On each level instance of this actor must move along some path. On different levels the paths are different.
How to implement this behavior?
If I add Spline component to this Blueprint then the path will be identical on all levels. But I need different paths. Maybe there is an ability to add a reference to another actor in the current level? But I cannot find it.

Have you tried this solution? You can always keep actor reference in spline(new spline on each level instance) or create "SplineManager" bp to deal with reference update.

Related

Duplicating ScritableObjects with Values per Script Unity

I am making a Multiplayer Game with MLAPI. The problem is, i have a ability system so every ability get executed over an ScritableObject. The problem is, if i have for example five Players in the scene all Players are referenced to the same ScritableObject. And so when somebody execute a ability. The other players are also doing it.
So my Question is can I duplicate my default ability ScritableObject so that every player has its own abilities ScritableObject but with the same Values as the default ability ScritableObject. I must do that over Script.
I know i could create a new ScritableObject and then make a method who paste my values. But maybe somebody has a better idea??????????
Afaik you can use Instantiate also for cloning ScriptableObject on runtime! Only you can of course not use any component taking more then the original parameter (which makes sense).
And the same way as ScriptableObject.CreateInstance this will of course not create an asset but only a runtime instance.

Accessibility of main from agent's statechart

May I know if main is accessible to all elements in the model?
The reason I ask is that I have created a simple M/M/n model with one resource type created through ResourcePool. The behaviour of the resource type is implemented using a statechart. I write a simple code in the action of a transition in the statechart, i.e.
if (agent_variable < main.my_parameter) { /* do something */ }
The code does not compile and give an error message "main cannot be resolved to a variable". I cannot figure out why the statechart cannot recognise main.
Thanks
Welcome to SOF, Stephan.
First, always use code-complete (Ctrl+space). You will then see what is and what is not possible to access from where you are. In your case, main would not even be an option :-)
Now, your model root (typically that is main) is always accessible via getModelRootAgent() but you will need to cast it to your Main class, i.e. ((Main)getModelRootAgent())
Otherwise, Main is accessible to all agents that are somehow embedded into Main. This is classic OOP principles. Your Resource agents are not actually an embedded population so no direct access to Main. (You can make that happen in the ResourcePool properties, though)

how to access a blueprint component with an Unreal pawn character spawned from the player start set up in the game mode?

I'm kind off a beginner, I was following the tutorial in the unreal documentation for direct blueprint communication, my problem is the following: when I set up a character blueprint so it accesses another blueprint with an object reference I want it so when my character is spawned that instance of my character is able to access the referenced object, currently it generates an error that pretty much says that that particular instance of my character is not the one that has the object reference variable set up, it only lets me assign it to characters in my scene yet these ones aren't the ones that are used to play when I hit play in the editor, the one used to play is set up so it's spawned by the game mode. thought this is probably not the way I would find it very useful to know a workaround to this.
C++
You can use GetComponentsByClass in BeginPlay(), e.g.:
TArray<UActorComponent*> Comps1 =
GetComponentsByClass(UStaticMeshComponent::StaticClass());
Or you can add tags in specified Component, and use GetComponentsByTag:
TArray<UActorComponent*> Comps2 = GetComponentsByTag(UStaticMeshComponent::StaticClass(), FName(TEXT("t1")));
They worked both for Blueprint Component and Native Component.
Blueprint
If there's only one character in level, you can use Get Actor of Class.
If there'are more than one characters, you can use Get All Actors of Class and foreach them.

SWIFT: Moving each child node along line path separately

I'm following the tutorial: http://www.raywenderlich.com/80586/make-line-drawing-game-sprite-kit-swift#
All is going well except that each one of the 'pig' child nodes from the Pig class all move together; in that when I draw a line for one node all the nodes follow the same path. If I then draw a line for another node, they all then follow that one.
What I'm trying to work out is how to make each pig node follow it's own path.
I've tried naming the nodes 'pig1', 'pig2' etc, while 'touches begin' does show specifically which node I'm touching, it seems the line path when created for one pig is applied to all and not each individual pig node.
I've contacted the author but with no reply, I would greatly appreciate any advice, be it another tutorial (can't find any myself).
Thanks
Apologies, despite thinking I was following the code correctly, I stupidly made the wayPoints array (which held the line coordinates) a global var for the Pig class instead of a object (node) specific.
Changed position of var declaration and all is good.

Game: General Structure and Game Item Structure

I am making a graphically simple 3D game in C++ using DirectX. The main problem I am having is with how to structure some things efficiently. Right now I know my goal for certain areas but not how to ideally perform them.
For instance, right now I am storing all meshes and textures in an Asset class with enumerated definitions pointing to each asset. All meshes and textures are loaded when the game starts by creating an Asset object and initializing it. From there I load meshes and textures to objects by assigning the pointer given by the Asset object. Is this the best way to go about this?
A harder topic is that of items. For the sake of argument I am going to say we are dealing with scenery. Right now my scenery needs the following:
A name
A mesh
Textures (optional)
Flags (such as Destructible, Flammable, etc.)
Status (such as Burning, Locked, Cursed, etc.)
Abilities (things the object actually does, such as becoming damaged when burning)
The first 5 things on this list are simply variables. But abilities are bothering me. The first 5 can all exist in one item class. But what I do not know how to do is somehow attach abilities to the object.
For example; I want the object to have the "Fire Nova" ability. At the start of each turn, the object damages anything near it.
For me, this means each object would need a "Trigger_Phase_TurnStart()" or some similarly named method and would then need a new "Fire Nova" class with its own unique action for that trigger and its own extra variables (Damage, Range, etc). So now I have the base object class and a new Fire Nova class that inherits from it.
But now what if I needed an object that has Fire Nova and Frost Nova and also Slowing Aura and other such abilities. Basically I need a way to add triggered effects to an object without needing a new object class for each of them.
So by the end I would be able to have say:
(pseudo code of the object's components)
name = Elemental Orb
mesh = "Mesh_Sphere"
textures[] = "Tex_Ice", "Tex_Fire"
flags = OF_Destructible
status = SF_Cursed | SF_Burning
abilities[] = Fire_Nova, Frost_Nova, Slowing_Aura
And this orb would simply be the object class with all these attributes. The object would then activate each stored ability's trigger at the appropriate turn phase for any actions to perform.
Right now I am thinking I might need to make a class for each ability possessing every turn-phase or action trigger (inherited from a base ability class) and have them perform the appropriate action when the object calls them from it's array of abilities. Would this be the best way to do this?
As a separate issue. Some flags would require additional variables that would otherwise be unnecessary. For example, Destructible would mean the object would have health whereas without the flag it wouldn't need it, or an Openable item would need an array of contents. What would be a good way to ration these variables to when they are needed? I do not need every wall to have health and an empty contents array for example.
Finally. Assuming the bullet-listed attributes above are all an item needs, how might you suggest I best store them? To clarify, I would like to be able to write:
CreateItem(ITEM_CHAIR);
and have this return the created object with name, mesh, textures, flags, status and abilities. What structure might be suitable for achieving such an end effect?
To summarise:
Does my current Asset storage seem feasible?
What is the best way to create abilities to attach to the object class without making numerous separate object classes?
Is there a way to limit the variables (or at least memory usage) when the associated flag is not present?
What structure or format would be best for storing fixed item definitions?
Sorry if this is a little long winded. If you cannot answer all the questions then an answer to one would still be appreciated. Question two is probably the largest priority for me right now.
Thanks for your time :)
I want only answer question 2 and it looks like you need a decorator pattern. In OOP a decorator pattern is useful when you have many ingredients and wants to decorate an object, for example a pizza. Unfortunately you need to create for each ingredient a separate class hence I think you have the right approach. The good thing is that with the decorator pattern you can wrap the object over and over with abilites classes and call only one method at the end to do all the stuff.