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"

Can't get projectiles to move in -X axis

I must be doing something really dumb because I can make them move in the positive X axis but not negative. I modeled my code on the twin stick shooter. When I fire a projectile, they appear, but they don't move. My UProjectileMovementComponent has its initial and max speeds set to -3000. When I go to spawn one I do:

 FVector FireDirection(-1.0f, 0.0f, 0.0f);
 const FRotator FireRotation = FireDirection.Rotation();
 FVector SpawnLocation = GetActorLocation() + socket_transform.GetLocation();
 World->SpawnActor(MyProjectileClass, &SpawnLocation, &FireRotation);

"socket_transform" is just the transform for the gun where the projectile fires from.

I thought perhaps the problem is setting a negative value for the speeds so I made them positive, thinking that the -1.0f for the X value of FireDirection would lead to it moving in the negative X axis direction but nope, it winds up just moving in the positive X axis.

Product Version: Not Selected
Tags:
more ▼

asked Jan 27 '15 at 04:08 AM in C++ Programming

avatar image

Architekt
66 13 16 22

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

1 answer: sort voted first

OK I figured it out. There were 2 issues. One, I stopped using the Speed variables and instead set the velocity variable. When I did that, it was in fact moving but it wasn't visible. Turns out the material I was using on the plane mesh that is my bullet needed to be set up to be two sided. Once I did that, everything works fine, and I was able to just do a SpawnActor without the rotation parameter, as the rotation is controlled by the velocity of the projectile.

more ▼

answered Jan 28 '15 at 12:06 AM

avatar image

Architekt
66 13 16 22

avatar image KyoKazehaya Aug 22 '18 at 01:09 PM

Thank you! I was trying to create a Transform with the Rotation and Location parameters and then apply a Velocity to the projectile later and it was causing odd behavior when trying to shoot in the -X axis. Removing the rotation from the transform solved the issue for me!

(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