• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Jun 02, 2013 at 07:16 AM by Fattie for the following reason:

Problem is not reproducible or outdated -- OP is asking a new nice questions

avatar image
0
Question by WarLordYT · May 18, 2013 at 05:22 AM · javascriptmovementtransform.positionmouselookparkour

transform.position over time? & mouselook rotate player?

I am trying to make parkour in my game, I have made raycasts and everything to make it work. But I have run into a few problems. Firstly, how do I make transform.position move over time? And secondly, how do I make the Mouselook rotate the player? Because the move direction is dependent on the rotation of the Z co-ordinate on the player variable?

(UnityScript for Parkour & C# for MouseLook (Unity's prefab mouselook))

Parkour Script

 var Player : GameObject;
 var Arms : GameObject;
 var SkyTrigger : GameObject;
 var HeadTrigger : GameObject;
 var WaistTrigger : GameObject;
 
 var VaultHeight : float = 1;
 var VaultLength : float = 2;
 
 var ClimbHeight : float = 2;
 var ClimbLength : float = 0.5;
 
 private var SkyBoole : boolean = false;
 private var HeadBoole : boolean = false;
 private var WaistBoole : boolean = false;
 
 private var ClimbEnabled : boolean = true;
 private var VaultEnabled : boolean = true;
 
 
 
 function Start()
 {
     Arms.animation.wrapMode = WrapMode.Loop;
     Arms.animation.Play("Idle");
 }
 
 function Update()
 {
     var SkyRay : RaycastHit;
     var HeadRay : RaycastHit;
     var WaistRay : RaycastHit;
     
     if(Physics.Raycast(SkyTrigger.transform.position, SkyTrigger.transform.forward, SkyRay, 1))
     {
         SkyBoole = true;
     }
     
     if(Physics.Raycast(HeadTrigger.transform.position, HeadTrigger.transform.forward, HeadRay, 0.25))
     {
         HeadBoole = true;
     }
     
     if(Physics.Raycast(WaistTrigger.transform.position, WaistTrigger.transform.forward, WaistRay, 0.25))
     {
         WaistBoole = true;
     }
     
     
     
     if(VaultEnabled)
     {
         if(WaistBoole && !HeadBoole)
         {
             ClimbEnabled = false;
             VaultEnabled = false;
             WaistBoole = false;
             HeadBoole = false;
             SkyBoole = false;
             Vault();
         }
     }
     
     
     if(ClimbEnabled)
     {
         if(WaistBoole && HeadBoole && !SkyBoole)
         {
             ClimbEnabled = false;
             VaultEnabled = false;
             WaistBoole = false;
             HeadBoole = false;
             SkyBoole = false;
             Climb();
         }
     }
     
     
     
 }
 
 function Vault()
 {
     Arms.animation.wrapMode = WrapMode.Once;
     ClimbEnabled = false;
     VaultEnabled = false;
     Arms.animation.CrossFade("Vault");
     yield WaitForSeconds (0.5);
     Player.transform.position.y=transform.position.y+VaultHeight;
     Player.transform.localPosition.z=transform.localPosition.z+VaultLength;
     yield WaitForSeconds (1);
     Arms.animation.CrossFade("Idle");
     Arms.animation.wrapMode = WrapMode.Loop;
     ClimbEnabled = true;
     VaultEnabled = true;
     WaistBoole = false;
     HeadBoole = false;
     SkyBoole = false;
 }
 
 function Climb()
 {
     Arms.animation.wrapMode = WrapMode.Once;
     ClimbEnabled = false;
     VaultEnabled = false;
     Arms.animation.CrossFade("Climb");
     yield WaitForSeconds (1.35);
     Player.transform.position.y=transform.position.y+ClimbHeight;
     Player.transform.localPosition.z=transform.localPosition.z+ClimbLength;
     yield WaitForSeconds (1);
     Arms.animation.CrossFade("Idle");
     Arms.animation.wrapMode = WrapMode.Loop;
     ClimbEnabled = true;
     VaultEnabled = true;
     WaistBoole = false;
     HeadBoole = false;
     SkyBoole = false;
 }

And MouseLook is Unity's Default Prefab

Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ExTheSea · May 18, 2013 at 07:45 PM 0
Share

Is your player a rigidbody, has a character controller or none of them both?

Also if the $$anonymous$$ouseLook Script really is just the standard script you can remove it from your question. $$anonymous$$akes it easier to read.

avatar image WarLordYT · May 19, 2013 at 03:19 AM 0
Share

$$anonymous$$y character has a Character Controller on it. & thanks for responding :)

avatar image ExTheSea · May 19, 2013 at 10:02 AM 0
Share

Then you can use CharacterController.$$anonymous$$ove ( http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.$$anonymous$$ove.html )

avatar image WarLordYT · May 20, 2013 at 07:48 AM 0
Share

Thanks, But how do i make it move up first with this mechanic?

avatar image WarLordYT · May 20, 2013 at 08:04 AM 0
Share

And how do I make it move a specific distance in the forward direction, ins$$anonymous$$d of the way it works right now?

Show more comments

0 Replies

  • Sort: 

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Vector3 of moving object always returns (0,0,0) 1 Answer

How can i Limit the Mouse X Axis for Mouse Look 2 Answers

Vector3 position changing without force being applied in the direction 1 Answer

MouseLook.cs:case of JavaScript 1 Answer

Curved transform.translate 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges