- Home /
fix sonic like script?
I have a a script that is meant to play with the character motor class when you collect a specific amount of objects. This is a 2D side scroller. The script dosnt make a compiler error but neither does it work.
var score : int = 2;
var speed : int = 10;
function Update () {
if(ScoreSystem.myScore == score){
speed += CharacterMotor.maxSidewaysSpeed;
}
}
I understand those are spaces, there is no tab button on a phone
Out of context and without more description, it is hard to tell you the right solution but:
A condition like this one, 'if (ScoreSystem.myScore == score)' is a bit dangerous since anything that increments 'myScore' beyond 'score' will make it false.
Your are increment 'speed', but you are not changing anything in the Character$$anonymous$$otor script.
Answer by Reeceg · Oct 14, 2014 at 02:21 AM
make these changes
var score : int = 2;
var speed : int = 10;
function Update () {
if(ScoreSystem.myScore > score)
{
CharacterMotor.maxSidewaysSpeed = speed;
}
}
if you cant understand what @robertbu means I suggest you read up more on javascript terms.
Its still not working :( if you wish I can tell you the other scripts I have been thinking of learning to code better
No, it's changeable, the character motor script is downloadable in the pre made assets
If its not a static var Im pretty sure you cant change it.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How would I play a sound in a certain range of an object? 1 Answer
Stop another sound from another script? 1 Answer
How to make the trigger work only once. (SOUND) 1 Answer
sound on key down help 2 Answers