Question by 
               PaincideStudio · Aug 06, 2018 at 04:30 PM · 
                c#collidervector3random.range  
              
 
              C# gameobject moving in specific area or collide with wall
Hello! 
 i made a script of gameobject keeps rotating and moving forward using Vector3. 
But the problem is gameobject keeps going through walls. 
What I want is making gameobject collide with wall or make gameobject moving in specific area. 
Please help! Here is the script.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class RandomMoveOctopus : MonoBehaviour {
 
     public GameObject Octopus;
     float speed = 1.0f;
     
     // Use this for initialization
     void Start ()
     {
         
     }
 
     void Update()
     {
         Vector3 randomDirection = new Vector3(Random.Range(-359.0f, -359.0f), Random.Range(0.0f, 0.0f), Random.Range(-359.0f, -359.0f));
         transform.Rotate(randomDirection);
         Octopus.transform.position = Octopus.transform.position + Octopus.transform.forward * speed * Time.deltaTime;
     }
 
     
 }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Set variable to position of collided object. 0 Answers
local scale not working? 2 Answers
Get an Inflated Mesh Collider (vertices and faces) 1 Answer
Failed to create agent because it is not close enough to the NavMesh 4 Answers
Trying to Generate Different Random Values for Position of Game Object Instances [C#] 1 Answer