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"

call constructor issue

hi all,

have 2 files. fireball and GameCharacter and need i make a fireball in gameCharacter and call function on this . GameCharecter.cpp :

 void AGameCharacter::LaunchSpell()
     AS_Fireball * test = NewObject<class AS_Fireball>();
     test->LaunchProjectile(this->GetActorLocation() , this->GetActorRotation() );

and a basic constructor in fireball.cpp :

 AS_Fireball::AS_Fireball(const class FPostConstructInitializeProperties& PCIP)
     : Super(PCIP)

this crash my editor, shoud dont be the right way ?

Product Version: Not Selected
more ▼

asked Sep 24 '14 at 05:02 PM in C++ Programming

avatar image

20 7 9 13

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Your fireball is an Actor, the NewObject() is for UObjects. Use Spawn() instead.

more ▼

answered Sep 24 '14 at 06:34 PM

avatar image

391 17 12 32

avatar image mamax49 Sep 24 '14 at 07:04 PM

thanks but i just need to have a firball to use function on fireball.cpp, i dont need to spawn him in the world

avatar image Moss Sep 24 '14 at 07:06 PM

But you have to spawn an actor to use it, if you just need a function from that actor you can check if the DefaultObject is enough for your needs.

avatar image mamax49 Sep 24 '14 at 07:21 PM

i use spawn() in fireball.cpp to make him in the world. i just need a reference to him to call this function

avatar image zamy Sep 24 '14 at 07:49 PM

You can't have a reference of an nonexistant object. ;)

avatar image mamax49 Sep 24 '14 at 07:57 PM

i fnish to resolve my probleme. i use :

 AS_Fireball * test = (AS_Fireball*)GetWorld()->SpawnActor(AS_Fireball::StaticClass());

with no location precised to dont see him in the world

avatar image zamy Sep 24 '14 at 08:04 PM

It simply get spawned at 0,0,0 ;) But onestly, if you need a reference to a not needed actor, maybe there's something wrong about your program structure. What are you trying to achieve?

avatar image mamax49 Sep 24 '14 at 08:08 PM

i have a character who can use spell so i have spell.cpp | projectileSpell : spell | fireball: projectileSpell

but the character can change spell anyway. all spell will be override by BP ti implement visual effect better so when i spawn a spell, i spawn a BP . and its a the launch() function in fireball.cpp will make the BP

avatar image zamy Sep 24 '14 at 08:22 PM

Aren't you overshooting it? You can easily customize it directly in C++, right after spawning, writing down a couple of function as you need: for example, one to change the mesh.

avatar image mamax49 Sep 24 '14 at 08:27 PM

i use BP to make the visual , add dynamic materail , particule emiter and more

(comments are locked)
10|2000 characters needed characters left
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