Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
0
Question by Deaninboston · Jan 01, 2016 at 07:07 AM · scripting probleminputtriggerif-statements

Linking Trigger to Input (or directly into Character Control script)

**I have created an AR array using Vuforia that will move a placeholder relative to the camera's position (when the user moves the camera). I have attached this placeholder to a collider object, which is surrounded by barriers, which are triggers. I want to substitute the triggers as button inputs for the character controls.

The idea is allow the player to cause their character to maneuver in the (FPS) game by changing the position of the camera forward, backwards, left, and right (relative to a marker). For a VR headset equipped with a camera, this will allow the player to control a character by making small movements of their body, for more immersive play.

In the script that comes with the FPS Rigid Body Character Controller (Standard Assets, Unity 5.0), I think I've found the reference to the input controls:**

public void UpdateDesiredTargetSpeed(Vector2 input)

         {

             if (input == Vector2.zero) return;

             if (input.x > 0 || input.x < 0)

             {

                 //strafe

                 CurrentTargetSpeed = StrafeSpeed;
             }

             if (input.y < 0)

             {

                 //backwards

                 CurrentTargetSpeed = BackwardSpeed;
             }

             if (input.y > 0)

             {

                 //forwards

                 //handled last as if strafing and moving forward at the same time forwards speed should take precedence

                 CurrentTargetSpeed = ForwardSpeed;

             }


**I believe I need to replace the "if (input.y < 0)" with a reference to the trigger that is in front of the collider object, which the player is moving around by moving the camera. I don't really know how to do that, which I'll come back to at the end.

Likewise, the "if (input.y < 0)" should be replaced with a reference to the trigger behind the collider object.

I'm not sure what to do with the side-to-side part, though: they changed up the syntax somehow and made that control "if (input.x > 0 || input.x < 0)"

So I have two problems.

1) How do I put a reference to the trigger (did the placeholder collide with the particular barrier) into the Character Controller script, and

2) How do I deal with the x-axis input, I have no idea what to do with this departure from the previous format...this is kind of a minor side question...please help me with #1, primarily!**

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

42 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 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 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

Vuforia (AR) Play animation on Target Image found (SCRIPT Help) 0 Answers

how to instantiate an object from an array above the previously instantiated object from the same array? 1 Answer

[SOLVED] Need help with my OnTriggerEnter code. 1 Answer

Acceleration input math problem. 0 Answers

How to Trigger/collision only once time per gameobject hit's? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges