NPC not fully moving to MoveTo part position

If I were to do this, create a normal sized Rig and connect the tiny rig to it, would it cause lag? The game will likely include many NPCs, so If not I would like to try it out, it doesn’t sound like too bad of an idea. :smiley:

3 Likes

Hey so I did what I said, however it seems it gotta be a little more complicated since I added a House placement system that allows players to rotate the house, I would have to add onto the values according to what orientation the house/NPC is. :confused:

2 Likes

You can use CFrame for this, that way you can use the same relative offset for every possibility, did it work though?

3 Likes

When walking out of the house yes, it went into the right position, however I was not able to test the NPC going back into the house because for some reason the Move script would not enable. Could you explain further on how I would use CFrame for this? I don’t know how to go about it.

2 Likes

Well so say the front of the house is pointing in the positive X direction, and the offset you had to add was Vector3.new(5, 0, 0), you could instead multiply with CFrame(0, 0, -5) (0, 0, -5 is 5 studs in the front direction), and that would work for any given rotation

3 Likes

have you tried changing the agent radius in the pathfinding settings?

local path = game:GetService("PathfindingService"):CreatePath({
	AgentRadius = 1,
	AgentHeight = 0.2,
	AgentCanJump = false
})
2 Likes

If I’m not mistaken this shouldn’t have any effect? That value sets how large gaps of nothing it can cross?

3 Likes

Hey sorry to sound dumb but I’m still not sure how I would implement this. Do I make an If statement for if the House is at a set orientation then multiply the cframe?

1 Like

No multiply it with the CFrame in any situation, it just will do the offset relatively to the rotation, rather than the same direction everytime

2 Likes

hey i just tested that with 2 different values and i found that it does infact matter

What exactly was the difference in behaviour?

see for yourself

1 Like

I see then! Interesting that the docs don’t mention this… @crumbsinmytoes try reducing the range to something very small (e.g. 0.05 or 0.1)

2 Likes

stealing my answer how could you

:frowning:

2 Likes

Sorry to disappoint, but I tried that and I didn’t fix the issue. Little NPC fella still doesn’t fully go to the correct position. :frowning:

I tried setting it to 0, 0.2, and 0.05

1 Like

Okay in that case, did the offset thing work? If yes, you can solve the problem with CFrame

1 Like

I’m not sure if I did it right but this is what I did,

local function GoOutside()
							if IsInside == true then
								Humanoid:MoveTo(Goal2.Position * CFrame.new(0,0,-5))
								Humanoid.MoveToFinished:Wait()
								wait(2)
								Move.Enabled = true
								IsInside = false
							end
						end

it just gives an error in the output saying invalid argument #1 (CFrame expected, got Vector3)

1 Like
Humanoid:MoveTo(Goal2.Position * CFrame.new(0,0,-5))

to

Humanoid:MoveTo(Goal2.Position * Vector3.new(0,0,-5))

(hopefully)

1 Like

No actually :sweat:
This should instead be something like:

Humanoid:MoveTo((House.CFrame * CFrame.new(House.Position - Goal2.Position) * CFrame(0, 0, -5)).Position)
2 Likes

Hi, sorry for the late response, but I did some testing for a while and I can’t get this to work. It still doesn’t move according to the House position. I had to set a primary part to the house and then get the cframe of said primary part, so there are no errors but the npc will still move only one direction, not depending on the orientation of the house. Btw, I’m sorry for using up so much of your time, thank you for all the help you’ve given so far. :smiley:

1 Like