How to teleport someone in ROBLOX after speaking to a npc - roblox

I need to know how to teleport a player after you speak to them in Roblox studio can someone please help me?

The simplest way I know to teleport a player to another player is to set their HumanoidRootPart CFrame to another player's HumanoidRootPart CFrame.
For teleporting a player to another Experience/World, I'd recommend using TeleportService as Kylaaa suggested.
To run the code for teleportation after the dialog ends would use a :Connect().
Example code for the CFrame teleportation, where "char" is the character of the player talking to the NPC and "target" is a random player's character.
char.HumanoidRootPart.CFrame = target.HumanoidRootPart.CFrame

Related

Unity C# Rigidbody vs Game Object?

I'm currently making a game in which I do not plan on adding any physics to the player. Player will be moved simply by modifying the position and rotation directly through code on a grid. Should my player be a Game Object instead of a Rigidbody? Or something else entirely? I'm a little new to Unity and don't quite know what would be best for the player.
Your player is always a GameObject, your player can't be of type RigidBody If i understand your question right you want to know if it's better to use a RigidBody or a custom script tomove your player ?
For easier use, if you are new to unity i would advice you to use the Rigidbody. You simply disable the gravity on it. If you go for a custom GameObject it's going to be more flexible but you will have more work to do (like collisions, movement calculation, etc...). You can disable the gravity on a Rigidbody with "useGravity = false" via code or in the inspector.
If you want to make your own script:
Here is a video than will explain how to do it: https://www.youtube.com/watch?v=AiZ4z4qKy44&t=246s&ab_channel=Comp-3Interactive
else:
Rigidbody Docs: https://docs.unity3d.com/ScriptReference/Rigidbody.html
Hope it help. Have a nice day !

Line of Sight AI for Enemies in a Topdown 2D unity game

I'm currently building a 2D topdown zombie survival game in unity where the player must run around an environment trying to get collectibles, I'm looking to have the zombies spawn from different points around the map when the player gets close to a spawn point, but id like for the enemies to only follow/chase the player when they can see them (Compared to what I have now in which they just move to the player straight away). Does anyone have any good links or ways of implementing this? all the tutorials I have looked at are for a playable character and not an enemy NPC.
Thanks
You need to:
Raycast from the NPC to the player to check for a clear line of sight
Create a field of vision to determine the angle of their peripheral vision
Ensure any successful raycast is within the angle of vision
If all of this is true then trigger the navmesh agent to walk towards the player.
Optionally, you can record the last player position where the NPC spotted the player; then if they break LOS (line of sight) the zombie moves to that position and looks around to re-establish LOS.

Jumpbutton with GroundCheck

Hey guys, I really new to unity and had a question about my button.
I´ve added a joystick which only controlls my player in the horizontal axes and wanted to implement a jump button. My JumpScript ist currently like that:
jumpscript
The problem is, that the player can jump as much as he wants and this is not what I want. How do I make a groundcheck ?
picture of my game
Put a collider on your players feet and jump only OnCollisionStay with the ground. It should do the trick. Like in here Unity 3D: How to stop being able to jump in the air

Unity- Colliding Passing Through

I made airplane shooter in Unity. First I make player and I already make all the code. And it works well. And then now I want to change the player object. I had already put the script and give same name and tag as the used player that I make. And the colliding is a mess. I can shoot enemies down. But the enemies can't shoot or hit me. The enemies bullet and the enemies passing through my player object.
I don't know why. Please help me to find the problem. Just tell me the possibilities of this problem cause.
Here is the screenshot of my new object component
Check if your Collider has the "Is Trigger" checked, that may be causing the error.

Unity3d Enemy Pushing MainCharacter Back

I am building a simple game where I want to AI enemy to chase and run to my main character and attack it but before I can get to the point where it is attacking I need to figure out this problem.
When my enemy gets to my main character it keeps going forward and keeps pushing my main character back instead of stopping how can I fix this? Both characters have rigidbodies and colliders.
Thanks
The enemy will never be at 0 distance to the player, because the colliders of both player and enemy. It's "impossible" and this means that the enemy will keep on running forward into the player forever.
To fix that, you should set a minimum distance for the enemy AI. This way, the enemy won't move unless the player is out of range.
If you're using Unity's default AI or any other kind of AI from the Asset Store, you will probably find this setting on the script controller. Just look at the inspector and check if you can modify it.
You could try to use "OnCollisionEnter". As far as I know, you could use collider as a trigger of a future action of the enemy and player. Maybe you could set collider in a wider range than that of the characters of yours. Set a specific range that when the player is within that range of the collider it would chase the player and would attack it once it has come to a specific distance then perform the script that you want.