KnowItAllGames

Horror AI

16 posts in this topic

Start simple, make a monster that exists (and does nothing).

Then gradually expand things in small steps:

- let it walk around randomly

- let it detect the player nearby

- let the player know the monster found him/her (or maybe not, if you want to surprise the player)

- pop up in front of the player (or whatever it should do to scare you).

2

Share this post


Link to post
Share on other sites
2 hours ago, Alberth said:

Start simple, make a monster that exists (and does nothing).

Then gradually expand things in small steps:

- let it walk around randomly

- let it detect the player nearby

- let the player know the monster found him/her (or maybe not, if you want to surprise the player)

- pop up in front of the player (or whatever it should do to scare you).

Yeh thats the thing you see im having trouble with the script to make it walk around randomly and making a jumpscare but i guess thats a whole other thing to work out

0

Share this post


Link to post
Share on other sites
41 minutes ago, KnowItAllGames said:

Yeh thats the thing you see im having trouble with the script to make it walk around randomly and making a jumpscare but i guess thats a whole other thing to work out

Walking is easy. If you use Unity then use a script to transform the location.

Next you should place waypoints on a level map, then by moving the monster using a script you target the waypoints. If it's a strait path then there will be no need for complex collision detection.

If you want more complex movement you need to read up on path finding. For your game the simple strait move will be enough.

Edited by Scouting Ninja
1

Share this post


Link to post
Share on other sites
38 minutes ago, Scouting Ninja said:

Walking is easy. If you use Unity then use a script to transform the location.

Next you should place waypoints on a level map, then by moving the monster using a script you target the waypoints. If it's a strait path then there will be no need for complex collision detection.

If you want more complex movement you need to read up on path finding. For your game the simple strait move will be enough.

You see its set in a forest and i would like my monster to just wander the forest aimlessly until it gets in range of the player(Its not a huge forest)

0

Share this post


Link to post
Share on other sites

Check the Unity NavMesh for this, remember that when you downloaded Unity it also downloaded the manual and scripting guide. All these things you are looking for is explain in there; keep them open at all times while working with Unity.

 

Now when it comes to navigation meshes Unity is limited, however it has all you will need for a game like yours.

1

Share this post


Link to post
Share on other sites

Do you have any code to show? Well, first thing did you do pathfinding? It will follow a path and you randomly generate a number for the path you want him to choose, if it see the player then you can make it automatically run to him or jump scare him or you can generate(again) a random number to tell if it has seen the player. If your code doesn't work I can fix it. 

1

Share this post


Link to post
Share on other sites
1 minute ago, Binkiklou said:

Do you have any code to show? Well, first thing did you do pathfinding? It will follow a path and you randomly generate a number for the path you want him to choose, if it see the player then you can make it automatically run to him or jump scare him or you can generate(again) a random number to tell if it has seen the player. If your code doesn't work I can fix it. 

I've actually just created the NavMesh but im not sure how i get my creature to roam the NavMesh do you think you could help?

also what kind of code would you like me to show you?

0

Share this post


Link to post
Share on other sites
Just now, KnowItAllGames said:

I've actually just created the NavMesh but im not sure how i get my creature to roam the NavMesh do you think you could help?

also what kind of code would you like me to show you?

Do you have code that you try to make it work? 

1

Share this post


Link to post
Share on other sites
6 minutes ago, Binkiklou said:

So you need help? Send me what you did and I'll try to finish it.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AIScript : MonoBehaviour {

	public float fpsTargetDistance;
	public float enemyLookDistance;
	public float attackDistance;
	public float enemyMovementSpeed;
	public float damping;
	public Transform fpsTarget;
	Rigidbody theRigidbody;
	Renderer myRender;

	// Use this for initialization
	void Start () {
		myRender = GetComponent<Renderer> ();
		theRigidbody = GetComponent<Rigidbody>();
	}
	
	// Update is called once per frame
	void FixedUpdate () {
		fpsTargetDistance = Vector3.Distance (fpsTarget.position, transform.position);
		if (fpsTargetDistance < enemyLookDistance) {
			myRender.material.color = Color.yellow;
			lookAtPlayer ();
			print ("Look at dah player");
		}
		if (fpsTargetDistance < attackDistance) {
			myRender.material.color = Color.red;
			attackPlease ();
			print ("Attack");
		} else {
			myRender.material.color = Color.blue;
		}
	}

	void lookAtPlayer(){
		Quaternion rotation = Quaternion.LookRotation (fpsTarget.position - transform.position);
		transform.rotation = Quaternion.Slerp (transform.rotation, rotation, Time.deltaTime * damping);
    }

	void attackPlease(){
		theRigidbody.AddForce (transform.forward * enemyMovementSpeed);

	}
}

This is my movement code for my creature and its all i have towards actually making it actually roam the NavMesh

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now