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 lecanardbleu · Apr 07, 2012 at 06:05 PM · fpsspeeddynamic

FPS Dynamic Speed variables

hi. im trying to make it so that my Fps can set his speed stat and that he will move faster with a higher number. I took the Fps that comes with unity and i tryed editing it, but it wont work. Help?

Yes i made sure that Spd in the Stats script is static.

Here's what i changed in the code

 class CharacterMotorMovement {


 // The maximum horizontal speed when moving
 @System.NonSerialized
 var Spd : float = Stats.Spd;
 @System.NonSerialized
 var maxForwardSpeed : float = Spd;
 @System.NonSerialized
 var maxSidewaysSpeed : float = Spd;
 @System.NonSerialized
 var maxBackwardsSpeed : float = Spd*.3;
 
 // Curve for multiplying speed based on slope (negative = downwards)
 var slopeSpeedMultiplier : AnimationCurve = AnimationCurve(Keyframe(-90, 1), Keyframe(0, 1), Keyframe(90, 0));
 
 // How fast does the character change speeds?  Higher is faster.
 @System.NonSerialized
 var maxGroundAcceleration : float = 30.0;
 @System.NonSerialized
 var maxAirAcceleration : float = 20.0;

 // The gravity for the character
 var gravity : float = 10.0;
 var maxFallSpeed : float = 20.0;
 
 // For the next variables, @System.NonSerialized tells Unity to not serialize the variable or show it in the inspector view.
 // Very handy for organization!

 // The last collision flags returned from controller.Move
 @System.NonSerialized
 var collisionFlags : CollisionFlags; 

 // We will keep track of the character's current velocity,
 @System.NonSerialized
 var velocity : Vector3;
 
 // This keeps track of our current velocity while we're not grounded
 @System.NonSerialized
 var frameVelocity : Vector3 = Vector3.zero;
 
 @System.NonSerialized
 var hitPoint : Vector3 = Vector3.zero;
 
 @System.NonSerialized
 var lastHitPoint : Vector3 = Vector3(Mathf.Infinity, 0, 0);

}

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 Bunny83 · Apr 11, 2012 at 06:49 PM 0
Share

If you want to bump your question, edit it or post a comment and try to improve the question. Don't post another question.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Apr 11, 2012 at 07:17 PM

Your problem is propably that you assigned the speeds only when the class get initialized. All your assignments after the variable declarations are done only once when the object is created. When you change Stats.Spd at runtime, Spd, maxForwardSpeed, maxSidewaysSpeed and maxBackwardsSpeed won't change, why should they...

If you change Stats.Spd you need to update the other variables as well. There are several ways.

One would be to update them each frame like this:

 // inside the UpdateFunction of the CharacterMotor.js
 private function UpdateFunction () {
     movement.Spd = Stats.Spd;
     movement.maxForwardSpeed = movement.Spd;
     movement.maxSidewaysSpeed = movement.Spd;
     movement.maxBackwardsSpeed = movement.Spd * 0.3;
     // [...]

Or to update them only when you change your Stats.

Comment
Add comment · 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 lecanardbleu · Apr 11, 2012 at 08:25 PM 0
Share

$$anonymous$$y error box says this

Assets/Standard Assets/Character Controllers/Sources/Scripts/Character$$anonymous$$otor.js(194,24): BCE0005: $$anonymous$$ identifier: 'Stats'.

I double checked and i spelled it right, but i don't know why.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Hello! When i put my 3D model my game lags. 0 Answers

First person shooter : Fight night champions dynamic health bar 0 Answers

How to get and change animation speed of animator? 2 Answers

Wild fluctuations in performance when built into an exe... 1 Answer

bullets flying through enemy 1 Answer


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