x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

What is wrong with this blueprint? Destroy actor

alt text

So I am completely new to Unreal 4 but not to programming. I am playing around. I am using a 'rolling ball' template for my game. Basically I have a cube (stretched out so more like a plane); when I touch the cube with my sphere (which the player controls) I want something to be destroyed ( I don't care what I just want the basics; here I am just destroying ANOTHER SPHERE (not the one the player controls) in the level). Why wouldn't this blueprint work?

P.S. nothing happens.

Product Version: UE 4.18
Tags:
screenshot-6.png (247.0 kB)
more ▼

asked Feb 05 '18 at 06:03 PM in Using UE4

avatar image

Dorthonion1
3 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You can't cast a Actor to a playerController, your cast fails. You will have to get the actors controller and cast that to playercontroler. Because playerController does not inherit from AActor

-Erik

more ▼

answered Feb 05 '18 at 06:38 PM

avatar image

erik321123
408 17 15 31

avatar image Dorthonion1 Feb 05 '18 at 07:14 PM

Thanks for the answer. I have some questions if you have the time: what exactly is a cast? At the moment I am interpreting it as something that makes sure the collision only counts if the thing that hits the cube is the thing I cast to. Also, does the actor have a controller? I thought only pawns had controllers.

avatar image erik321123 Feb 05 '18 at 07:22 PM

Yes only pawns have controllers, but pawns inherit from actor. So a instance of a class deriving from actor cán have a controller.

A cast is very complicated, so I am trying to keep it simple here.

A cast tries to get a more basic class of the object you are passing it, for example a Actor inherits from UObject, so you could cast a a Actor to a UObject, so you have more basic methods, and members.

This can only work 'up' (to a more basic version), 'down' (to a more complex version) doesn't work. A cast returns NULL if it fails, the cast node has that a part that checks if it is not NULL and then executes the corresponding branch.

This way you can use a cast to check if a object derrives from a class thus make sure it is of a certain type.

A cast also can't work if the two classes aren't related in a way. In example actor to playercontroller. You could however cast actor->controller to playerController.

I hope this still makes sense for you.

-Erik

avatar image Dorthonion1 Feb 05 '18 at 07:26 PM

Thanks for the help, I guess I'll just watch more youtube vids :)

avatar image erik321123 Feb 05 '18 at 07:32 PM

Easiest way to fix it for you is to cast the other actor to the character class of your player (asuming it has one)

avatar image ThompsonN13 Feb 05 '18 at 11:07 PM

another way you could go it also is to have: get player character -> == -> branch. those three nodes in a row would do nearly the same thing as a cast except it would trigger your script when any character controlled by the player entered the trigger volume.

avatar image ThompsonN13 Feb 05 '18 at 11:14 PM

casting isnt all that hard at its most basic casting is just comparing two things to see if they are alike. for instance if you have a ford mustang and cast to car then it would succeed since its a type of car. if you tried to cast a mustang to plane it would fail since they are not alike. its all about hierarchy mustang can be cast to car since it has 4 wheels an engine and the basic functionality is the same. car however cannot be cast to mustang since it is more specialized (not all cars are fords, not all cars are sports cars, etc). all mustangs are cars but not all cars are mustangs.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question