[Help] Making a 2D shooter. Having a variety of difficulties, including figuring out collision.

Help

I'm doing a basic Game Fundamentals course, and they've started us out on UE4. The first assignment's due soon and I'm incredibly lost with Blueprints, as it's not how I'm used to doing things at all.

This is one of the main bullet blueprints, sending it forward. However, when fired, it seems to not fire from the ship, instead firing nearby. The enemies do the same, and I'm not sure how to fix this.

However, the bullets work fine - when aimed properly through the glitchy placement, they destroy the ships, which animate. The player also takes damage when hit. So that's not an issue.

Another collision problem: I need to make the player teleport if they hit the sides of the screen - to the other side of the screen. I'm thinking the Teleport blueprint would work for this, but I don't know how to set something like 'if player is at x location' for the Teleport to trigger on. I'm assuming it's something with the 'Get Actor Location' blueprint, but I don't know how to make it a condition.

If anyone knows any resources I can use to help with additional parts of this assignment, please let me know - I've got to set up a deposit area and all, too, and I've only got a week to finish everything.

Posted May 1, 2016, 8:45 AM UTC

210
bloons•

Can you show the blueprint where you spawn the bullets?

1
HanhulaOP•

Sure, here's what I'm using for the enemy and for the player.

1
CmdrKeransIndie•

What's the 250uu Y value on the bullet spawn location for? Could that be the problem?

Try offsetting the location and see where the bullets spawn from (break vector, add to/subtract from the floats) and feed the modified values back into the SpawnActor Bullet.

Or alternatively get the location from somewhere more reliable - like a socket you could add to the Player blueprint in the Viewport tab, at the exact location you want bullets to spawn from.

1
CmdrKeransIndie•

For the teleporting at the side of the screen you could simply move the player to the other side when they reach a certain co-ordinate - take a look at this thread on the forums for a few ideas:

https://forums.unrealengine.com/showthread.php?33348-Screen-Wrapping-in-3D

1
HanhulaOP•

Thank you! This is exactly what I needed, I didn't know this existed!

1
HanhulaOP•

So, I'm reading this through and I'm a little confused as to how it works, bearing in mind that I'm an absolute beginner and my teacher's idea of teaching is to hand us a 'tutorial', not explain what we're doing and us follow along with every step.

I understand that I'm meant to call the viewport size from the player controller using Get Viewport Size, and I understand how to create vectors: I'm just not sure how to make it move to the other side when reaching a certain coordinate.

For example. Get Viewport Size to understand that I'm looking at something like 2200 across, 1200 up and the player controller's in the middle of that (shouldn't this use the camera..?).

How do I write something like 'Player hits x=1200' to connect to SetActorLocation? I really don't understand how the person in the forums has done it, and it's the thing I need to learn to be able to implement this.

1
CmdrKeransIndie•

Sorry you haven't had a reply until now. We're probably in different timezones.

What you could try doing is test every frame where the player is, and if they are above a certain X coordinate, set them back to the other side of the screen.

So use an event tick event, feed it into your logic to check where the player is, and a separate sequence which runs concurrently (use a sequence node) or after the tester sequence which puts the player to the other side of the screen if necessary.

Does that make any sense to you? I've not done anything like this myself so I can't give you specifics (nor do I personally think that's in the spirit of a class assignment! :)) but I'm happy to help.

1
HanhulaOP•

Thank you! We're definitely in different timezones, your reply was at something like 4am for me. Thank you for not giving me specifics: that wouldn't be fair to the rest of the class.

I'm understanding what you're suggesting, and I'll have to test it out myself after class. My only issue is that I'm not entirely sure how to use the nodes. Do you think something like linking GetActorLocation to EventTick and a vector '>' (would => work too?) connecting GetActorLocation to SetActorLocation could function? I'm hypothesising this as the event constantly getting the actor's location and if it's equals or larger than the right boundary, it sets the actor's location to the left boundary. I'd need to somehow have two vectors/location setters for each boundary, then again for top and bottom.. is there a vector pin that does this? Am I misunderstanding how it works?

1
CmdrKeransIndie•

You can't compare a vector directly - you have to break it into floats first and compare the X Y Z values, and then make the vector again later.

I was able to make this work quite easily in the Twin Stick template by adding new logic to the Sequence node which already exists in the TwinStickPawn blueprint.

Basically have a sequence node off an event tick in your player pawn, which goes to a Compare Float node. Feed that with your player location Y or X value (GetActorLocation, Break Vector), comparing it to your max limit and then reassemble (make) the vector and feed it back into a SetActorLocation which is activated by the appropriate output of the Compare Float node. You'll only feed back two existing values into the make vector node - the last one will be your new value which you can type directly into the make vector node.

You can then activate another Compare Float off the 'this is all OK' pin from the first one, which then compares if the ship is below the minimum value, and sends it back to the max point instead.

1