3D Survival Game Tutorial | Unity | Part 3: Selecting Items with Raycast & Creating Simple AI

preview_player
Показать описание
#survivalgame #tutorial #unity
In this tutorial series, we will create a 3D survival game with Unity & C# as the scripting language.
We will start with basic FPS movement, inventory building, and crafting systems.
Learn how to pick up items and more.
Little by little, we are going to add different features that are common to survival open-world games.
This series is a bit more advanced and fast-paced, but I will try to explain everything I do.
Any questions are welcome.

Selection Manager Script:
InteractableObject Script:
Ai Movement Script:

White Rabbit free asset:

Sphere/Circle Sprite

Survival Series Playlist:

💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾
Between my full-time job and my family life,
I try to find free time to create content for this channel.
You can support me and help this channel keep growing:
💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾💾

💻 This Is My Development Setup (Affiliate): 💻
============
Main Monitor:
Secondary Monitor:
Graphics Card:
CPU:
RAM:
Keyboard:
Mouse:
Headphones:
Microphone:
Рекомендации по теме
Комментарии
Автор

For anybody getting the object not set to an instance ...
And that is using TextMeshPro in the newer Unity Versions
Here is what you should do

Add this to the top of the selectionmanager:
using TMPro;

Then u also have to change these 2 lines:
Text interaction_text; TextMeshProUGUI interaction_text;
interaction_text = interaction_text =

I hope this helps :)

timothygaming
Автор

Im really enjoying going over these videos,
Ive never really working in 3d, and these explanations are really good.
Ive had various problems when adding stuff to the game world, and had a lot of fun tracking down the issues, and figuring out where I went wrong.

TheRealKaiProton
Автор

First off, amazing tutorials and explanations! The best I have came across, great at explaining the little details.
I laughed so hard when you were creating the rabbits and you went over one and said "oh I stepped on one" as if the rabbit felt it.
Keep doing what you are doing, we really appreciate it!!!

alexd
Автор

If your like me and don't want the selectionmanager to select stuff across the map, you can simple change this

if (Physics.Raycast(ray, out hit))

to

if (Physics.Raycast(ray, out hit, 10))

bobbysmurf
Автор

Alright, first of all, I'm loving this tutorial series. I'm planning to follow them through until I have something cool playable.

Second, reading some comments about problems other had, and making a little research, I found a way to use TextMeshPro instead of the legacy text.

your code should be something like this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;


public class SelectionManager : MonoBehaviour
{

public GameObject InteractionInfo;
TextMeshProUGUI interaction_text;


private void Start()
{

interaction_text =
}

void Update()
{
Ray ray =
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
var selectionTransform = hit.transform;
InteractableObject interactable =

if (interactable)
{

interaction_text.text = interactable.GetItemName();
}
else
{

}

}
}
}



The gist of it is using TextMeshProUGUI as a variable type, instead of just TextMeshPro. Don't forget to use "using TMPro" at the top of the code too. Hope this helps someone.

daywedie
Автор

Mike thank you for your tutorials!
It's motivate me to explore all details and even try to do some modifications.

Dialogues_about_Ukraine
Автор

best tutorials i ever seen about unity
thank you so much

anasouladbenlahcen
Автор

I subscribed because of how good this tutorial is :)

Super_Nova
Автор

If you cant find the animator tab, its under window in the ribbon alog the top window/animation/animator
if you are getting The type or namespace name 'InteractableObject' could not be found. its because you need to create a seperate c# script named 'InteractableObject' and then place the code in description for it in it.

TinkeringNoob
Автор

i love you, this is best tutorials i've seen

chenkevin
Автор

for anyone who has problems with the item name not showing when you look at an object, Make sure that the object has a collision box. I've been pulling my hair out for hours with this problem, yet the solution was kind of obvious haha. Could just be a problem for me because I'm using different assets. anyways, love your videos and how you explain everything. Thanks man

thedrumminggeek
Автор

Hey Mike, Thanks for the tutorial. Just a small suggestion: it's always very helpful to provide the assets you use in your tutorial to the viewer. For example, even something simple as importing that white sphere you use for the reticle took me like two hours since I needed to download image software and figure out how to create the right type of image.

MrThijsdc
Автор

how come when im trying to sort out the selection manager the interaction info ui doesnt show up
please help

seanpainter
Автор

Hi, I like the way you explain, glad I found you. I will definitely follow this series. It would also be good if, during the explanation, you would add how the script would be done if, for example, instead of the first person, you used the third person, what would the difference be.. As for the rest, it's a really good tutorial... Best regards, and keep up the good work ...subscribed

dkordy
Автор

When i reach the point of adding the component Selection Manager i dint get the Interaction_info_UI, the same when i add the component Interactable object i dont get the Item Name option that appears in your video. it seems that many are having this issue. is there a way to fix this, i tried everything so far, out of ideas...

MultiDegh
Автор

{can someone help please} ive ran through this vid before on other projects and the [Selectionmanager] and [interactableobjects] files (WORKED) but now they dont show names and ive ran through it over and over and cant fix it

SAVAGEGHXST
Автор

thanks,
i have problem about rabbit, in inspector i don't have box cellinder and rigidbody, then in Hierarchy show 2 side box blue one side black

danyarsniper
Автор

Hi Mike, can you help me, if for the third person point of view the coding script part is the same as in the video or something has been changed and I direct it to the object, the writing doesn't appear like the one in the video because I use the third person point of view, is there a solution? Thank you

Dazeza
Автор

Can you help me pls?
My rabbit animation is not working. I tried to put them as in the video but still its not working

alisherka
Автор

My bunny keeps sinking about 15 less that the normal height and then it goes in the same height in which ever direction, floating bunny. I tried the rigidbody but that did not help much, any suggestions?

CyberStudios
join shbcf.ru