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 /
avatar image
0
Question by Muzz 1 · Apr 03, 2011 at 01:01 PM · javascriptcharactercharactercontrollerjump

Translation of an object

I'm trying to move a character upwards by a set amount when it touches a jump-pad. Here is the code so far:

var velocity : Vector3; var jumpSpeed : float = 50; var maximumSpeed : float = 30; var minimumSpeed : float = 10; private var controller : CharacterController; function Awake(){ controller = GetComponent(CharacterController); } function Update(){ controller.SimpleMove(velocity); } function OnControllerColliderHit (hit : ControllerColliderHit){

if (hit.gameObject.name == "Jump") { transform.Translate(Vector3(0,jumpSpeed,0) * Time.deltaTime); }

Now, the problem is that this moves the character upwars (y-axis) by a certain amount in the space of 1 frame. How do I change this so it is over a longer time period?

Comment
Add comment · Show 1
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 Justin Warner · Apr 03, 2011 at 01:04 PM 0
Share

Just a lil thing.... If you make the jump pad actually translate up on collision, the player does fly up in the air... It works exactly like a jump pad... Lol.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Joshua · Apr 03, 2011 at 01:08 PM

At the top, add

var time : float = 1.0;

and in the part where it says Time.deltaTime, behind that but before the ) add

* time

now you can, in the editor, change the time from one frame to what ever you'd like.

Comment
Add comment · Show 4 · 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 Muzz 1 · Apr 03, 2011 at 01:49 PM 0
Share

So it reads transform.Translate(Vector3(0,jumpSpeed,0) * Time.deltaTime*time);, yes?

avatar image Muzz 1 · Apr 03, 2011 at 01:58 PM 0
Share

Not working, sorry.

avatar image Joshua · Apr 03, 2011 at 02:30 PM 0
Share

Once you've done what I said go to where you have this script attached to, go to the inspector view and now there is a variable called time which you can change.

avatar image Muzz 1 · Apr 03, 2011 at 07:59 PM 0
Share

No, that doesn't help, even when I set it to much bigger values.

avatar image
1

Answer by Owen-Reynolds · Apr 03, 2011 at 04:43 PM

I think Joshua is assuming the jump pad is TALL -- as tall as how far you jump. Every frame you are in it, you go up, like an anti-grav elevator.

If you really have a JUMP pad, you could set velocity to some trial-and-error number (10 is about 1G, so 20-40 is a good start.) Depending how your movement works, rigidbody.velocity.y=30; or velocity.y=30;

Comment
Add comment · Show 5 · 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 Muzz 1 · Apr 03, 2011 at 07:59 PM 0
Share

So how would I script that?

avatar image Joshua · Apr 03, 2011 at 09:15 PM 0
Share

replace the transform.Translate part with rigidbody.velocity.y=jumpspeed; and tweak that.

avatar image Muzz 1 · Apr 04, 2011 at 10:52 AM 0
Share

It's not a rigidbody.

avatar image Owen-Reynolds · Apr 05, 2011 at 12:16 AM 0
Share

controller.Simple$$anonymous$$ove(velocity); is moving the object. That means the velocity variable controls the speed it moves.

avatar image Muzz 1 · Apr 06, 2011 at 12:32 PM 0
Share

And? What do I need to do?

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

No one has followed this question yet.

Related Questions

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

How do I fix my player jumping code? 2 Answers

Impact Sound When Jumping? (JavaScript) 1 Answer

CharacterController unexpectedly moving up 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