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. 

How to add a for loop to this?

This is the whole blueprint (inside the event graph of a blueprint class - actor) It spawns the actor and applies a position transform. How can I add a for loop to this, when it uses Event Tick (it will crash UE4), to loop a spawn command to spawn the actor in the blueprint class indefinitely (add a delay for the loop, but no delay for the event tick b/c that will slow down the position transform).

Any help would be greatly appreciated!

Needs a for loop

Product Version: UE 4.9
Tags:
untitled.jpg (46.9 kB)
more ▼

asked Oct 18 '15 at 02:48 AM in Blueprint Scripting

avatar image

nmm131
170 47 49 60

avatar image thankstipscom Oct 18 '15 at 03:33 AM

confused.

Youre trying to spawn duplicates of the actor every tick? or youre trying to change the transform of a spawned actor every tick?

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

6 answers: sort voted first

So I found a solution:

The spawn point was set using TargetPoint I did use EventTick for implementing my for loop -> delay (which delayed the tick to every 2 seconds, as I put in the delay node) -> spawnActorFromClass

Because the actor has a ProjectileMovementComponent, it would move in a coordinate direction without the help of the orange spawnTransform on the spawnActorFromClass (which was just set to the TargetPoint to place its spawn position)

Final Blueprint

Without the delay after the for loop, the Event Tick caused this to happen: alt text

untitled3.png (146.1 kB)
untitled2.png (399.0 kB)
more ▼

answered Oct 19 '15 at 06:34 PM

avatar image

nmm131
170 47 49 60

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

Hi man , if i get what you want :

Take your actor , and make a CustomEvent, call it SpawnWithDelay. Make your customevent spawn the actor, then add the Delay node, and put in appropriate value, then call again your custom event.

in the Event begin Play, call your customevent

This Spawn endlessy your actor , but you can change the value of the delay to get the right time.

In the event tick of your spawned actor, via blueprint, add a simple " Add Actor Relative Location" to make it go endlessy in one direction .

more ▼

answered Oct 18 '15 at 09:52 AM

avatar image

Est_engine
1.2k 58 12 62

avatar image Est_engine Oct 18 '15 at 04:18 PM

First, you get the error in red , as unreal say: The spawn in your spawn event, need a transform. you need to tell him where put the new spawned actor and wich rotation and scale give him. so pin out from the, and say him make transform, and complete all the pin , give him a location , a rotation , and a scale, you can make them all manually or take them from other Actors.

I suggest you to try to use at first, an actor without complex component. and see if you can spawn that Actors as you want.

Using the projectile movementcomponent, mean that your projectile will fall for gravity, slow for air , have a velocity an accelleration and a lot of thing. you will probably take a few times to get what you want. if you want that your projectile go steady in a direction

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

you have to pay attention when use SET or ADD location/rotation.... Set will define the amount you give, Add will add that amount. look here all these nodes will move toward the X.alt text

actor move.jpg (223.7 kB)
more ▼

answered Oct 18 '15 at 06:33 PM

avatar image

Est_engine
1.2k 58 12 62

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

i notice only now that you are spawning a projectile test ? from a projectile test? Lets do this clear.! here a working one. alt text

more ▼

answered Oct 18 '15 at 07:29 PM

avatar image

Est_engine
1.2k 58 12 62

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

Unreal crash because your actor ProjectileTest create a duplicate of himself, that begin play , and create a duplicate of himself to endlessy.(without never reaching the first delay)

You have to call your spawn event , from outside your ProjectileTest. you can place this in your level , or in another actor.

but the ProjectileTest absolutely must not spawn himself.

Actor A (gun) have the on begin event -call customeventSpawnBullet

Actor A have the custom event SpawnBullet , that spawn a bullet and re-call this event witha delay.

Actor B (the bullet) have nothing inside himself.

more ▼

answered Oct 18 '15 at 09:37 PM

avatar image

Est_engine
1.2k 58 12 62

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

I didnt understand what you commented here.

Unreal implement loops of many types.

ProjectileMovementComponents doesnot need any info in the event tick

You can spawn Actors everywhere. giving him coordinates manually or picking them up from other Actors.

You can also spawn dozen of Actors with physics or projectilemovement component at evey frame.

i am sure that unreal can handle what you want to do, if you do it fine. Unreal just crash if you endlessy create Actors that create Actors endlessy without pass a single frame. try to rebuild my example above , keep it simple. one step at time.

more ▼

answered Oct 18 '15 at 10:02 PM

avatar image

Est_engine
1.2k 58 12 62

avatar image Est_engine Oct 18 '15 at 10:16 PM

This not spawn actor, but add a static mesh to your own actor.

I suggest you to restart from 0 take your time and copy the example above.

step 1. make a bullet that dragged in the scene, just go alone at x+

step 2 . make an actor BOSS that spawn worker. Every worker say hello.

step 3 . make the boss spawn the bullet

step 4 make the boss turn , and spawn bullet accordingly with his direcion.

(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