Unreal Engine 4 Blueprints - how to set branch condition on get actor of class - game-engine

I have been working on a simple game in Unreal Engine 4. I am trying to make it so when a player is hit by a cube they take damage. However, I am stuck on creating a condition. I have previously used:
to set up a condition where a player only takes damage if they are touched by the cube (In my cube pawn blueprints).
This doesn't work however - when trying to set-up my health bar:
This shows that I am now using entirely new variables to attempt to get a successful updating bar.
Without setting it up so when a cube hits the player, the player takes damage, the player will take damage from simply jumping at walking into other surfaces.
I have created a function that successfully updates my current health and max health so I don't need to show, or need help with the maths or updating the widget. Is there a way for me to use the branch to create an if statement that checks the contact is form a cube?
I am quite new to blueprints and have mostly developed through the use of tutorials. If you need clarity on my question or you don't understand what I am asking please leave a comment and I will try to update. I have looked long and hard for an answer, but I have found that Unreal Engine 4 hasn't got many questions that I can tailor the answer to my situation. If the answer is already in another post on this website, comment saying so and I will remove this post.
Thanks for any help you can give me :)
(This also has a itch.io page for me to quickly share to my friends so I will also credit the person who helped me there)

If I've understood your question correctly, I believe you are just asking how to check if the cube has hit the player character and not some other actor.
Instead of using an if statement as you suggested, you can just cast the Other Actor property to your first person character. If the cast is successful then it hit the character, if the cast fails, it hit something else. You can then call the damage function which you said you've already created. Below is a basic example you could use in your cube blueprint. You will also need to make sure you have a collision box surrounding your cube mesh (and your character, but I can already see that in your screenshot).

Related

Problem with PDDL code using conditional effects

I'm trying to solve a Pacman-styled PDDL problem and there's a particular scenario I've been stuck on for days now. I'm getting the classic
ff: goal can be simplified to FALSE. No plan will solve it
which means the issue is trivial and logic related. However, I'm new to PDDL and can't seem to figure out what's causing it.
The problem is simple, Pacman (P) has to eat the Food (F), but two ghost agents (G) are blocking it. To get past them, Pacman needs to consume the Capsule (C), making him invisible.
(Edit: I've deleted the question as it was part of an assignment. I managed to solve the issue and will post the solution as soon as the assignment is graded.)
In this thread: About PDDL in AI planning #haz mentioned a good methodology to debug your PDDL Model when the goail is unreachable from the initial state.
The best way to test this out is to follow the following strategy: (1) write down a plan you know will solve it; (2) starting with the first action, set the goal to the precondition; (3) repeat to the end. If that fails, start changing the initial state to what you expect the complete state to be during the execution of the plan. – haz May 1 at 2:04
I uploaded a new version which is able to find a solution (if Ghosts are not in the path of foods):
http://editor.planning.domains/#read_session=c7Vez9nrti
Two main issues:
you never delete GhostPos, but it appears in the goal formula
If GhostPos is on the way to a FoodPos, then you can never reach the food as the move action requires not to be a Ghost.

In Qualtrics, how to hide a slider from being displayed until a response is given?

I'm trying to create a survey containing several slider-type questions, asking participants to select a point on a line to indicate their experience of different emotions. For example:
Not at all anxious -----------------------|---------------------Extremely anxious
These questions are meant to serve as visual analogue scales (VAS), often used in my field but typically administered via paper/pen. A digital VAS would be very useful for my research, but I have 2 problems with the Qualtrics format.
First, I need to hide the vertical slider until participants selects a point on the line (in effect removing any visual "starting point" that can influence responses). Second, I can't force participants to respond to every question, so I need a way to distinguish those who skip a question/don't answer (including code to check if the slider was displayed or not displayed when the participant chooses to continue to the next question might work, so that Qualtrics stores no response for that question if the slider is still hidden).
Thanks for the help! I'm not a coder, so I would really value any and all advice!

VB.Net Label and radio button problems

I am creating a VB.net program where kids can answer exercises on multiplication. I have a problem cause my professor wants me to print the results of the exercises where the kids answer 10 randomized multiplication problems . the summary which he wants me to create should contain the questions, the kid's answer to every question, and if it is wrong, the correct answer should also be prompted. the problem is, the questions are randomly generated integers displayed at the same label control, how am I gonna call every question if that's the case? well, that's just the first problem. my second problem is about radio buttons, see, there are three difficulty levels, the easy, medium, and hard level. every difficulty level has 10 questions. what I want to happen is that when a kid finishes answering one level, the radiobutton that corresponds to it should be disabled. here's the picture for my problem to make sense to you .
and the summary must be contained on a different form.

Need SpriteKit collision to occur only on first contact

I currently have two nodes in use, one of which is a boat (polygon) and the other a straight vertical rectangle. The boat needs to be a polygon so that it can be hit via projectiles, however this causes me problems when it collides with the vertical rectangle due to the many sides it's coming into contact with. Hence a piece of code I want ran only once is instead ran multiple times.
Is there anyway to make the collision detection only function for the first contact so that it doesn't repeatedly call?
I'm aware of setting the categoryBitMask to 0 however doing so renders the boat unable to be hit by anything else- something I don't want. Additionally I considered using a boolean variable to only run the code once whilst the boat is passing through, however as previously mentioned, due to the different sides, the code think it's passed through when in fact it's just hitting another side of the boat.
I don't have much code to show here other than setting physics bodies so I don't think it's necessary, but inside didBeginContact() I'm using a categoryBitMask comparison to check for collisions.
I may have not explained this very well, in which case I apologize, my English is not the best!
If anyone can help, it'd be much appreciated, thanks.
You can combine the individual physics bodies of your ship into a single body with
+ (SKPhysicsBody *)bodyWithBodies:(NSArray *)bodies
and then test for contacts with the composite body instead of the individual components.
If you are subclassing your node then simply create a BOOL property for it.
BOOL alreadyHit;
If you are not subclassing, use the SKNode's userData dictionary and create an entry for the same.

Modelica - how to implement a constructor for a record

What is the best way to implement a constructor for a record? It seems like a function should be able to return a record object in the instantiation of the record in some later model higher up the tree, but I can't get that to work. For now I just use a bunch of parameters at the top of the record that populate the variables stored in the record, but it seems like that will only work in simple cases.
Can anyone shed a little light? Perhaps I shouldn't be using a record but a model. Also does anyone know how the PDE functionality is coming? The book only says that it is coming, but I have seen some other things around.
I don't seem to have the clout to add tags (which makes sense, since my "reputation" is lower than yours) so sorry about that. I thought I had actually added one at one point, but perhaps I am mistaken.
I think you need to be clear what you mean by constructor since it has a very specific meaning in Modelica. If I understand your question correctly, it sounds like what you want to do is create an instance of a record that has some fields that are specified in the constructor arguments and from those arguments a bunch of other fields in the record are computed. Is that correct?
If so, there is a mechanism to do this. You mention "the book" but it isn't clear which one you mean. If it is mine, it definitely has no mention of these so called "record constructors" because it is too old. I do not know if Peter Fritzson's book mentions them either. However, they do exist and are documented in Section 12.6 of the Modelica 3.2 specification.
As for PDEs, there has been work into this kind of thing but nothing has really been done within the design group on this topic. I would add that if you want to solve either elliptical or parabolic PDEs on regular grids, this isn't too hard even with the current language. The only real drawback is that most tools probably don't handle sparsity very efficiently. Irregular grids would also be possible, but then you get into complicated basis functions. Finally, hyperbolic PDEs are, in my opinion, quite tricky (in any environment) due to the implicit physical constraints between time and space which are difficult to express (i.e. the CFL condition).
I hope that answers your questions so far.
I can only comment on your question regarding the book of Peter Fritzson. He confirmed that he's working on an update and he hopes to get it ready 'in the course of 2011'.
Original post here:
http://openmodelica.org/index.php/forum/topic?id=50
And thanks for initiating the modelica tag, I might be useful in the near future for me too... :-)
regards,
Roel