I wanted to add trails after tires using Hypertrails by @aglitchman , but when I rotate the position of the object with trail model and script that is slightly offset towards the origin of the car - one of the trails is behaving unexpectedly: (the red and blue lines are for debugging - velocity and forward/frontal direction of the car)
You can see above, that one tire trail (left one of the car) behaves precisely, like I would like them to be, so that it’s head position is changed, but the trail is “drawn” on the track and left untouched, but the other one (right one of the car) somehow “translates” the whole trail.
If I removed them both and created again right trail game object first, and then add left game object - the behaviour is the same, but the last created one behaves wrongly.
And I update their position with the simple script:
local function update_trail_positions()
local car_rotation = go.get_rotation("/car")
local car_position = go.get_world_position("/car")
local new_pos_left = car_position + vmath.rotate(car_rotation, TRAIL_LEFT_OFFSET)
local new_pos_right = car_position + vmath.rotate(car_rotation, TRAIL_RIGHT_OFFSET)
go.set_position(new_pos_left, "/trail_left")
go.set_position(new_pos_right, "/trail_right")
end
I don’t want to make them simply child of the car object, because it causes the whole trail to rotate also:
Oh, ok, I wanted to emphasize the problem to you, so I changed color of the left trail to red and right trail to blue , but it turned out both are blue!
So, I guess, changing properties of script instances in the collection are “overwriting” themselves?
Somehow I can’t change properties - changing anything in the first in Outline script is overwritten by the second one, for both instances? I don’t understand this behavior
Don’t attach trail game objects to any parents. Otherwise, its behavior will be hard to control because you need to recalculate offset of the trail mesh to be relative to the parent and so on . Just change trail objects position on every update from the script that controls car and it should work fine.
No, the properties are (supposed to be) per instance of the script.
So, if you’ve set two different colors on the scripts, start by verifying that your properties are correct in your init() function of the script, by printing them out.
Add a test property to compare with, like a number, to verify with.
go.property("test", 0)
and change it to e.g. 1 and 2 for the scripts respectively.
function init(self)
print("init test", self.test)
end
and it should print out
init test 1
init test 2
But I also noticed that it’s the new functionality of editing vertex attributes in the editor.
Perhaps that part isn’t working fully as intended yet.
EDIT: Another thing is to check if bundling helps (as we then run Bob for building the content)
I have an error here (there is not faststream - is it some kind of extension?)
ERROR:SCRIPT: hyper_trails/trail_maker.lua:198: attempt to index global ‘faststream’ (a nil value)
stack traceback:
hyper_trails/trail_maker.lua:198: in function init_buffers
hyper_trails/trail_maker.script:19: in function reset_trail
hyper_trails/trail_maker.script:26: in function <hyper_trails/trail_maker.script:25>