Announcement

Collapse
No announcement yet.

Actor and Pawn Naming issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Actor and Pawn Naming issue

    in the picture I am getting the actor that I am overlapping with and comparing it to all the classes of that vehicle to get the correct vehicle ID.
    the problem is that the name is coming up different. it was working for a little bit and then I tried adding a vehicle spawner and then the naming got all messed up.
    is there a better way to do what i'm trying to do or a way to clear the actor/pawn names?
    Attached Files

    #2
    Originally posted by weignerm View Post
    in the picture I am getting the actor that I am overlapping with and comparing it to all the classes of that vehicle to get the correct vehicle ID.
    the problem is that the name is coming up different. it was working for a little bit and then I tried adding a vehicle spawner and then the naming got all messed up.
    is there a better way to do what i'm trying to do or a way to clear the actor/pawn names?
    Rather than leave it to the engine to decide what to call things, it's much better to put tags on actors. That way you can use GetActorsWithTag ( or class with tag ) and find them later. You can have more than one tag, so you can have a name, a type etc...

    Comment


      #3
      I have looked for a way to set a tag to an actor or component in blueprints and have not found one. What I want to do is a for loop that every time a vehicle or item spawns it assigns a tag of "Vehicle" + Number. Number + 1.
      Last edited by weignerm; 02-13-2020, 05:34 PM.

      Comment


        #4
        My approach would be to not save the object name, but the object itself. This also applies for the ID, normally you can always access objects via their reference. If you still need the ID, you can do it inside your BP_Vehicle_SUV (or in a base class of that). There, you create an int "ID", and on BeginPlay set it like this:

        Click image for larger version

Name:	Unbenannt.PNG
Views:	63
Size:	64.3 KB
ID:	1720974‚Äč

        Now you can ask for your ID from anywhere. There are more complex ways with using a separate manager class that registers every vehicle when it's spawned, but for the problem you described this solution should give you values.

        Add: If you're deleting vehicles during runtime, this won't work cleanly! In this case, you have to assign an IDCounter in your custom game mode, which the counts up in your Vehicle's BeginPlay and sets the ID of the vehicle.

        Hope this helps

        Comment


          #5
          that would get the number of items in the array and not the name of placement of the vehicle in the array

          Comment

          Working...
          X