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 /
This question was closed May 01, 2017 at 02:04 PM by Landern for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by anish200501 · Apr 24, 2017 at 11:55 PM · swimmingswim

How do I make my FPS Character swim when in contact with water?

I am having a problem trying to make my FPS Controller swim when in contact with WaterProDaytime. I am using the standard Unity FPS controller. Also when I reach my river, I want my FPS to slow down, but NOT swim. Any ideas? Please help me!!!! Also please give me some sample code on this matter. Thank you!!

Comment
Comments Locked
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

2 Replies

  • Sort: 
avatar image
2
Best Answer

Answer by Duke_Hast_Mich · Apr 28, 2017 at 05:54 AM

I just added an ocean sized box collider to my central island, set it to trigger and put this script on the terrain

 private void OnTriggerEnter(Collider Other)
     {
         GameObject DaveyJones = Other.gameObject;
         if (DaveyJones.tag == "Player")
         {
             DaveyJones.GetComponent<Rigidbody>().drag = 5;
             DaveyJones.GetComponent<Rigidbody>().useGravity = false;
             DaveyJones.GetComponent<Rigidbody>().velocity = new Vector3(0f, -.5f, 0f);
             DaveyJones.GetComponent<Animator>().SetBool("IsSwimming", true);
             DaveyJones.GetComponent<MouseControls>().isSwimming = true;
 
         }
     }
     private void OnTriggerExit(Collider Other)
     {
         GameObject DaveyJones = Other.gameObject;
         if (DaveyJones.tag == "Player")
         {
             DaveyJones.GetComponent<Rigidbody>().drag = 1;
             DaveyJones.GetComponent<Rigidbody>().useGravity = true;
             DaveyJones.GetComponent<Rigidbody>().velocity = new Vector3(0f, 0f, 0f);
             DaveyJones.GetComponent<Animator>().SetBool("IsSwimming", false);
             DaveyJones.GetComponent<MouseControls>().isSwimming = false;
 
         }
     }
 
 
Comment
Comments Locked · Show 1 · Share
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 anish200501 · Apr 29, 2017 at 02:13 PM 0
Share

Hi Duke_Hast_$$anonymous$$ich, what is DaveyJones?

avatar image
0

Answer by Arminyazdian · Apr 27, 2017 at 12:53 PM

Hi. Unfortunately im not familiar with that package. But it should have a variable for the speed of the character. If you couldnt find it, you can search for it in the script maybe it is private. After you found it, just check if there is a collision between the character and the specific place by OnCollisionEnter() and then, use GetComponent to change the speed. The script would be like this:

 public GameObject myObj;
 void OnCollsionEnter(Collision Other){
 if(Other.gameObject.tag=="Tag"){
 myObj.GetComponent<ScriptName>().variableName...;
 }
 }

just put the game object which has the fps script in it and put the tag of the place which you want to have collision with in "Tag" and in ScriptName write the name of the fps script name and for variableName put the name of the speed variable. Good luck.

Comment
Comments Locked · Share
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

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Modifing Standard Assets FPC to swim 0 Answers

Unity 5, script for a character to be able to swim in water 1 Answer

How to make character swim 0 Answers

Adding Swimming and diving to character motor? 2 Answers

Allowing player to swim or dive in water? 6 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