Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Jun 25, 2012 at 04:16 AM by Bruno-Fludzinski for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by Bruno-Fludzinski · Jun 18, 2012 at 02:09 AM · platformflyingfpc

Flying Platform jump

In my game i want to make a platform, and when my FPC steps on it, he flies up in the air, i've tried some codes but I cant figure it out, if anyone knows how to do this that'd be great. Thanks!

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

2 Replies

  • Sort: 
avatar image
2
Best Answer

Answer by aldonaletto · Jun 19, 2012 at 05:41 PM

If you're using the First Person Controller prefab, create a trigger, child it to the platform and add this script to it:

var speed: float = 50;

function OnTriggerEnter(other: Collider){ var cMotor: CharacterMotor = other.GetComponent(CharacterMotor); if (cMotor){ cMotor.SetVelocity(Vector3.up * speed); } } This does not move the platform, but will shoot the FPC up at speed meters per second.

Comment
Add comment · Show 6 · 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 Bruno-Fludzinski · Jun 19, 2012 at 05:45 PM 0
Share

thank you so much and by creating a trigger do you mean make a box collider on a empty GameObject and tick is trigger?

avatar image aldonaletto · Jun 19, 2012 at 05:47 PM 0
Share

Yes, this is the best method (you could also create a cube, adjust its dimensions, set Is Trigger and uncheck $$anonymous$$esh Renderer to make it invisible)

avatar image Bruno-Fludzinski · Jun 19, 2012 at 05:55 PM 0
Share

Ok it works thank you so much!

avatar image aldonaletto · Jun 19, 2012 at 07:10 PM 0
Share

One more thing: the function SetVelocity in the Character$$anonymous$$otor has an error: it sends a message OnExternalVelocity with the default option RequireReceiver, what generates errors "Send$$anonymous$$essage has no receiver". You can comment out this line in the CharacterController.js script (line 582 in the current version) to eli$$anonymous$$ate the error messages, or add the option DontRequireReceiver to it, like below:

 Send$$anonymous$$essage("OnExternalVelocity", Send$$anonymous$$essageOptions.DontRequireReceiver);
avatar image himanshu619 · Dec 15, 2012 at 09:22 AM 0
Share

@Aldo it's giving me an error "Assets/Scripts/test/flip.js(2,13): BCE0018: The name 'Character$$anonymous$$otor' does not denote a valid type ('not found'). Did you mean 'UnityEngine.CharacterJoint'?"

Show more comments
avatar image
2

Answer by Berenger · Jun 18, 2012 at 02:15 AM

I suppose you want the platform to go up for a hosrt distance and extremely fast, so it can throw the player. Physic is probably not the best way to go as it would probably leave the player behind. I suggest you use a collider on the platform only to detect when the player step on it, then parent the player to the platform, make it go up, unparent and finally add a force upward to the player. A big one. You might have to save the player's velocity when he steps one the platform.

Comment
Add comment · Show 10 · 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 Bruno-Fludzinski · Jun 18, 2012 at 02:18 AM 0
Share

it sounds like it'l work but i dont know how to do what you said--can you explain a little please

avatar image Berenger · Jun 18, 2012 at 02:48 AM 0
Share
  • Add a collider on the platform. Set isTrigger to true.

  • Add a script on the platform, implement the function OnTriggerEnter

  • Inside, check if it is the player, if it is, the player's transform.parent becomes the platform's transform.

  • Either with an animation or a coroutine, make the platform rise very fast as to throw the player, like if there was a spring below.

  • At the highest point of that animation, unparent the player (player.transform.parent = null) and add a force on his rigidbody.

Is it better ?

avatar image Bruno-Fludzinski · Jun 18, 2012 at 02:54 AM 0
Share

eh ill try

avatar image Bruno-Fludzinski · Jun 18, 2012 at 03:02 AM 0
Share

steps 3, 4, 5 dont make much sense, so sorry

avatar image Berenger · Jun 18, 2012 at 03:47 AM 0
Share

step 3 is :

 function OnTriggerEnter( col : Collider ){
     if( col.CompareTag( "Player"  ) // don't forget to set that on your player
     {
         col.transform.parent = transform;
     }
 }

step 4 and 5, how do you animate the platform currently ?

Show more comments

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

Issue on moving using CharacterController 1 Answer

How to import project? 3 Answers

test platform 1 Answer

Collision on the bottom? 1 Answer

the component interactive cloth can be added to gameobject because it is not supported by selected platform 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