PlaceholderGames / DinoPark-2017

repo for Dino Park 2017, the testbed for CS3S667
2 stars 0 forks source link

Field of view script - Seeing itself fix. #51

Open 14065258 opened 6 years ago

14065258 commented 6 years ago

Just change the code where you're adding the target to the list like i've done below and it should fix the problem of it seeing itself.

image

14065258 commented 6 years ago

Update- Just realised that this doesn't help those who want to see more then one of itself. so if you got two raptors and you want to see if its in range of each other or not. So hold on and let me change it to see if i can fix that instead.

14065258 commented 6 years ago

Update - Change the code to look like this instead. image

Found out aswell that the reason why you see two raptors for every one is because it has two box collides instead of one. So just disable one of them and you should be good to go.

ghost commented 6 years ago

Ive also found that my Field of View script sees 2 of every other object it sees: image image

I only have 1 raptor in my scene

14065258 commented 6 years ago

disable one of the box colliders for the raptor. for some reason its got two image

DoctorMikeReddy commented 6 years ago

There are two box colliders as not having one on the legs allows the Rapty to walk through low obstacles that should stop it. Removing duplicates might be better, and could be done by me in the FieldOfView script, as I am going to be using box colliders for the combat system, which would mean 3-4 colliders per dino. The alternative is to have one box collider per model, but that would limit the realistic collisions.

DoctorMikeReddy commented 6 years ago

Ok, I have found two ways to remove duplicates. One is to construct the list (with repetitions) and then use the myList.Distinct().ToList(); functions to remove duplicates; this requires Linq to be in the includes at the top ( using.System.Linq ). The other is to check whether an object is already in the list, using something like: if (myList.IndexOf(value) == -1 ) { myList.Add(value); } I'll repost this as a separate issue, so others find it.