Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » FREE Project Downloads & Recources » Scripts » Wall avoid script

Wall avoid script

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Wall avoid script on Sat Feb 15, 2014 9:50 am

NXTGenerationsTv


Member [Lv. 3]
Member [Lv. 3]
ok so if you want to create one yourself etc. please stay awy from using triggers (tried it with triggers , so you dont have to have special tags , but it really sucked)
so now i think ive got my final script (feel free to use it any kind you want and let me know if you have any improvements)
Code:
var AnimName ="wallavoid";
var Range : float = 0.2;
var Weapons : GameObject;
private var resetTime = 15;
function Update(){
  var hit : RaycastHit;
  var direction : Vector3  = transform.TransformDirection(Vector3.forward);
  Debug.DrawRay(transform.position , direction * Range , Color.blue);
   
    if(Physics.Raycast(transform.position , direction , hit, Range)){
 
    if(hit.collider.gameObject.CompareTag("Wall"))
      {
      Weapons.animation[AnimName].speed = 1;
      Weapons.animation[AnimName].time = resetTime;
      Weapons.animation.Play(AnimName);
        }
  else
        {
      Weapons.animation[AnimName].speed = -0.7;
      Weapons.resetTime =animation[AnimName].time;
      Weapons.animation[AnimName].time = animation[AnimName].length;
      Weapons.animation.Play(AnimName);

        }

 
  }
 }

View user profile

2 Re: Wall avoid script on Sat Feb 15, 2014 10:17 am

iWutten


Member [Lv. 0]
Member [Lv. 0]
Thanks for the script.

View user profile

3 Re: Wall avoid script on Sat Feb 15, 2014 1:48 pm

NewDeveloper


Moderator
Moderator
Hey it's nice to see that you are helping out the community.
I hope to see youu activity on the forum.

--New Developer

View user profile

4 Re: Wall avoid script on Sat Feb 15, 2014 5:43 pm

Hey yes, it is great that you are helping out the community! Thanks for the post!

View user profile http://www.youtube.com/user/misterninjaboy

5 Re: Wall avoid script on Sun Feb 16, 2014 9:11 am

NXTGenerationsTv


Member [Lv. 3]
Member [Lv. 3]
MisterNinjaBoy wrote:Hey yes, it is great that you are helping out the community! Thanks for the post!
no problem if we all help each other we can really grow this forum up Razz

View user profile

6 Re: Wall avoid script on Wed Feb 26, 2014 1:19 pm

Silent Killer


Member [Lv. 3]
Member [Lv. 3]
So this script is like the one on fps constructor that when you're close to a wall the gun goes up or whatever it is called?

View user profile

7 Re: Wall avoid script on Wed Feb 26, 2014 4:50 pm

NXTGenerationsTv


Member [Lv. 3]
Member [Lv. 3]
Silent Killer wrote:So this script is like the one on fps constructor that when you're close to a wall the gun goes up or whatever it is called?
yeah thats exactly what it does

View user profile

8 Re: Wall avoid script on Fri Mar 21, 2014 10:29 pm

BryceCain25


SUPER MODERATOR
SUPER MODERATOR
Fantastic sir!

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum